# hello2.py # Walker M. White (wmw2) # August 20, 2013 """Hello World GUI. The purpose of this App is to test that Kivy is install correctly.""" # Import a bunch of Kivy stuff import kivy from kivy.app import App from kivy.uix.floatlayout import FloatLayout from kivy.uix.label import Label from kivy.graphics.vertex_instructions import Rectangle from kivy.graphics.context_instructions import Color from kivy.config import Config class Panel(FloatLayout): """Drawing canvas to display the label. A simple Kivy panel that contains Hello World.""" def __init__(self,**kw): """Constructor: Makes a new Panel for drawing shapes Precondition: **kw are Kivy key-word arguments""" # Pass Kivy arguments to super class. super(Panel,self).__init__(**kw) # Make the background solid white color = Color(1.0,1.0,1.0,1.0) self.canvas.add(color) rect = Rectangle(pos=self.pos, size=self.size) self.canvas.add(rect) # Add the label label = Label(text="Hello World!") label.color = [0.0,0.0,0.0,1.0] label.size_hint = (1,1) label.font_size = 48 label.bold = True self.add_widget(label) class HelloApp(App): """Primary application object. Create and run to get the panel.""" def build(self): """Build application with a single internal panel""" Config.set('graphics', 'width', '450') Config.set('graphics', 'height', '250') return Panel(size=(450,250)) # Application Code if __name__ == '__main__': HelloApp().run()