blob: 64b38216a66650067c38440f25b728369ba74860 [file] [log] [blame]
Guido van Rossum35820f71994-10-07 09:55:26 +00001from Tkinter import *
2
3# This is a program that tests the placer geom manager in conjunction with
4# the packer. The background (green) is packed, while the widget inside is placed
5
6
7def do_motion(event):
8 app.button.place({'x' : event.x,
9 'y' : event.y})
10
11def dothis():
12 print 'calling me!'
13
14def createWidgets(top):
15 # make a frame. Note that the widget is 200 x 200
16 # and the window containing is 400x400. We do this
17 # simply to show that this is possible. The rest of the
18 # area is inaccesssible.
19 f = Frame(top, {'width' : '200',
20 'height' : '200',
21 'bg' : 'green'})
22
23 # note that we use a different manager here.
24 # This way, the top level frame widget resizes when the
25 # application window does.
26 f.pack({'fill' : 'both',
27 'expand' : 1})
28
29 # now make a button
30 f.button = Button(f, {'fg' : 'red',
31 'text' : 'amazing',
32 'command' : dothis})
33
34 # and place it so that the nw corner is
35 # 1/2 way along the top X edge of its' parent
36 f.button.place({'relx' : '0.5',
37 'rely' : '0.0',
38 'anchor' : 'nw'})
39
40 # allow the user to move the button SUIT-style.
41 f.bind('<Control-Shift-Motion>', do_motion)
42
43 return f
44
45root = Tk()
46app = createWidgets(root)
47root.geometry("400x400")
48root.maxsize(1000, 1000)
49root.mainloop()
50