(py-indent-right, py-outdent-left): new commands, bound to C-c C-r and
[python/dscho.git] / Demo / tkinter / matt / canvas-w-widget-draw-el.py
blob545385923184effa9d2c351ce57478d267678e66
1 from Tkinter import *
3 # this file demonstrates the creation of widgets as part of a canvas object
5 class Test(Frame):
6 def printhi(self):
7 print "hi"
9 def createWidgets(self):
10 self.QUIT = Button(self, {'text': 'QUIT',
11 'fg': 'red',
12 'command': self.quit})
13 self.QUIT.pack({'side': 'bottom', 'fill': 'both'})
15 self.draw = Canvas(self, {"width" : "5i", "height" : "5i"})
17 self.button = Button(self, {"text" : "this is a button",
18 "command" : self.printhi})
20 # note here the coords are given in pixels (form the
21 # upper right and corner of the window, as usual for X)
22 # but might just have well been given in inches or points or
23 # whatever...use the "anchor" option to control what point of the
24 # widget (in this case the button) gets mapped to the given x, y.
25 # you can specify corners, edges, center, etc...
26 self.draw.create_window(300, 300, {"window" : self.button})
28 self.draw.pack({'side': 'left'})
32 def __init__(self, master=None):
33 Frame.__init__(self, master)
34 Pack.config(self)
35 self.createWidgets()
37 test = Test()
39 test.mainloop()