blob: 969fefb18699eeb24237325edc438153d6df5437 [file] [log] [blame]
Guido van Rossum35820f71994-10-07 09:55:26 +00001from Tkinter import *
2
3# this shows how to spawn off new windows at a button press
4
5class Test(Frame):
6 def printit(self):
7 print "hi"
8
9 def makeWindow(self):
10 fred = Toplevel()
Guido van Rossum89cb67b1996-07-30 18:57:18 +000011 fred.label = Label(fred, text="Here's a new window")
Guido van Rossum35820f71994-10-07 09:55:26 +000012 fred.label.pack()
13
14 def createWidgets(self):
Guido van Rossum89cb67b1996-07-30 18:57:18 +000015 self.QUIT = Button(self, text='QUIT', foreground='red',
16 command=self.quit)
Guido van Rossum35820f71994-10-07 09:55:26 +000017
Guido van Rossum89cb67b1996-07-30 18:57:18 +000018 self.QUIT.pack(side=LEFT, fill=BOTH)
Guido van Rossum35820f71994-10-07 09:55:26 +000019
20 # a hello button
Guido van Rossum89cb67b1996-07-30 18:57:18 +000021 self.hi_there = Button(self, text='Make a New Window',
22 command=self.makeWindow)
23 self.hi_there.pack(side=LEFT)
Guido van Rossum35820f71994-10-07 09:55:26 +000024
25 def __init__(self, master=None):
26 Frame.__init__(self, master)
27 Pack.config(self)
28 self.createWidgets()
29
30test = Test()
31test.mainloop()