# button.py # Walker M. White (wmw2) # November 8, 2012 """Module to show off a callback function in an application.""" from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button from kivy.config import Config from kivy.app import App class ButtonMain(BoxLayout): """Main panel with a single button""" def __init__(self,**kw): """Constructor: make a new panel with a button""" super(ButtonMain,self).__init__(**kw) button = Button(text='Click Me!',size_hint=(1,1)) self.add_widget(button) # Set the callback function button.on_press = self.my_callback def my_callback(self): """Function to call when button is pressed.""" print 'Hello World!' class ButtonApp(App): """Instance is an application that draws according to touch.""" def build(self): """Build application with a single internal panel""" """Build application with a single internal panel""" Config.set('graphics', 'width', '200') Config.set('graphics', 'height', '200') return ButtonMain(size=(200,200)) # Application Code if __name__ == '__main__': ButtonApp().run()