Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 1 | from Tkinter import * |
| 2 | |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 3 | # note that there is no explicit call to start Tk. |
| 4 | # Tkinter is smart enough to start the system if it's not already going. |
Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 5 | |
| 6 | class Test(Frame): |
| 7 | def printit(self): |
Collin Winter | 6f2df4d | 2007-07-17 20:59:35 +0000 | [diff] [blame^] | 8 | print("hi") |
Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 9 | |
| 10 | def createWidgets(self): |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 11 | self.QUIT = Button(self, text='QUIT', foreground='red', |
| 12 | command=self.quit) |
Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 13 | |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 14 | self.QUIT.pack(side=LEFT, fill=BOTH) |
| 15 | |
| 16 | # a hello button |
| 17 | self.hi_there = Button(self, text='Hello', |
| 18 | command=self.printit) |
| 19 | self.hi_there.pack(side=LEFT) |
Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 20 | |
| 21 | def __init__(self, master=None): |
Tim Peters | 182b5ac | 2004-07-18 06:16:08 +0000 | [diff] [blame] | 22 | Frame.__init__(self, master) |
| 23 | Pack.config(self) |
| 24 | self.createWidgets() |
Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame] | 25 | |
| 26 | test = Test() |
| 27 | test.mainloop() |