blob: 724cb97fdf04dcce1edba9375266af30836fc435 [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
4
5def do_motion(event):
6 app.button.place({'x' : event.x,
7 'y' : event.y})
8
9def dothis():
10 print 'calling me!'
11
12def createWidgets(top):
13 # make a frame. Note that the widget is 200 x 200
14 # and the window containing is 400x400. We do this
15 # simply to show that this is possible. The rest of the
16 # area is inaccesssible.
17 f = Frame(top, {'width' : '200',
18 'height' : '200',
19 'bg' : 'green'})
20
21 # place it so the upper left hand corner of
22 # the frame is in the upper left corner of
23 # the parent
24 f.place({'relx' : '0.0',
25 'rely' : '0.0'})
26
27 # now make a button
28 f.button = Button(f, {'fg' : 'red',
29 'text' : 'amazing',
30 'command' : dothis})
31
32 # and place it so that the nw corner is
33 # 1/2 way along the top X edge of its' parent
34 f.button.place({'relx' : '0.5',
35 'rely' : '0.0',
36 'anchor' : 'nw'})
37
38 # allow the user to move the button SUIT-style.
39 f.bind('<Control-Shift-Motion>', do_motion)
40
41 return f
42
43root = Tk()
44app = createWidgets(root)
45root.geometry("400x400")
46root.maxsize(1000, 1000)
47root.mainloop()
48