# This program demonstrates a Button widget. # When the user clicks the Button, an # info dialog box is displayed. import Tkinter class MyGUI: def __init__(self): # Create the main window widget. self.main_window = Tkinter.Tk() # Create a Button widget. The text 'Click Me!' # should appear on the face of the Button. The # do_something method should be executed when # the user clicks the Button. self.my_button1 = Tkinter.Button(self.main_window, \ text='Click Me!', \ command=self.do_something) self.my_button2 = Tkinter.Button(self.main_window, \ text='Click Me Too!', \ command=self.do_something_too) # Pack the Button. self.my_button1.pack() self.my_button2.pack() self.label = Tkinter.Label(self.main_window,text="Choose") self.label.pack() # Enter the Tkinter main loop. Tkinter.mainloop() # The do_something method is a callback function # for the Button widget. def do_something(self): self.label.configure(text="Clicked button 1") def do_something_too(self): self.label.configure(text="Clicked button 2") def main(): # Create an instance of the MyGUI class. my_gui = MyGUI() main()