Guido van Rossum | 35820f7 | 1994-10-07 09:55:26 +0000 | [diff] [blame^] | 1 | from Tkinter import * |
| 2 | |
| 3 | # this shows how to spawn off new windows at a button press |
| 4 | |
| 5 | class Test(Frame): |
| 6 | def printit(self): |
| 7 | print "hi" |
| 8 | |
| 9 | def makeWindow(self): |
| 10 | fred = Toplevel() |
| 11 | fred.label = Label(fred, {'text': "Here's a new window",}) |
| 12 | fred.label.pack() |
| 13 | |
| 14 | def createWidgets(self): |
| 15 | self.QUIT = Button(self, {'text': 'QUIT', |
| 16 | 'fg': 'red', |
| 17 | 'command': self.quit}) |
| 18 | |
| 19 | self.QUIT.pack({'side': 'left', 'fill': 'both'}) |
| 20 | |
| 21 | |
| 22 | # a hello button |
| 23 | self.hi_there = Button(self, {'text': 'Make a New Window', |
| 24 | 'command' : self.makeWindow}) |
| 25 | self.hi_there.pack({'side': 'left'}) |
| 26 | |
| 27 | |
| 28 | def __init__(self, master=None): |
| 29 | Frame.__init__(self, master) |
| 30 | Pack.config(self) |
| 31 | self.createWidgets() |
| 32 | |
| 33 | test = Test() |
| 34 | test.mainloop() |