Class around PixMap objects that allows more python-like access. By Joe Strout.
[python/dscho.git] / Demo / tkinter / matt / window-creation-w-location.py
blob0ec4e094ec90eb91644715242bdb29bd125f2664
1 from Tkinter import *
3 import sys
4 ##sys.path.append("/users/mjc4y/projects/python/tkinter/utils")
5 ##from TkinterUtils import *
7 # this shows how to create a new window with a button in it that
8 # can create new windows
10 class QuitButton(Button):
11 def __init__(self, master, *args, **kwargs):
12 if not kwargs.has_key("text"):
13 kwargs["text"] = "QUIT"
14 if not kwargs.has_key("command"):
15 kwargs["command"] = master.quit
16 apply(Button.__init__, (self, master) + args, kwargs)
18 class Test(Frame):
19 def makeWindow(self, *args):
20 fred = Toplevel()
22 fred.label = Canvas (fred, width="2i", height="2i")
24 fred.label.create_line("0", "0", "2i", "2i")
25 fred.label.create_line("0", "2i", "2i", "0")
26 fred.label.pack()
28 ##centerWindow(fred, self.master)
30 def createWidgets(self):
31 self.QUIT = QuitButton(self)
32 self.QUIT.pack(side=LEFT, fill=BOTH)
34 self.makeWindow = Button(self, text='Make a New Window',
35 width=50, height=20,
36 command=self.makeWindow)
37 self.makeWindow.pack(side=LEFT)
39 def __init__(self, master=None):
40 Frame.__init__(self, master)
41 Pack.config(self)
42 self.createWidgets()
44 test = Test()
45 test.mainloop()