PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 4ms RepoModel.GetById 16ms app.codeStats 0ms

/Demo/tkinter/matt/window-creation-more.py

http://unladen-swallow.googlecode.com/
Python | 35 lines | 25 code | 7 blank | 3 comment | 0 complexity | af9f0c0222bc2eea8946dc999f534a03 MD5 | raw file
 1from Tkinter import *
 2
 3# this shows how to create a new window with a button in it
 4# that can create new windows
 5
 6class Test(Frame):
 7    def printit(self):
 8        print "hi"
 9
10    def makeWindow(self):
11        fred = Toplevel()
12        fred.label = Button(fred,
13                            text="This is window number %d." % self.windownum,
14                            command=self.makeWindow)
15        fred.label.pack()
16        self.windownum = self.windownum + 1
17
18    def createWidgets(self):
19        self.QUIT = Button(self, text='QUIT', foreground='red',
20                           command=self.quit)
21        self.QUIT.pack(side=LEFT, fill=BOTH)
22
23        # a hello button
24        self.hi_there = Button(self, text='Make a New Window',
25                               command=self.makeWindow)
26        self.hi_there.pack(side=LEFT)
27
28    def __init__(self, master=None):
29        Frame.__init__(self, master)
30        Pack.config(self)
31        self.windownum = 0
32        self.createWidgets()
33
34test = Test()
35test.mainloop()