Added more cross-reference targets and tidied up list of useful handlers.
[python.git] / Demo / tkinter / matt / placer-simple.py
blob30d9e9e901dba368d58e6ba856db3107c798c171
1 from Tkinter import *
3 # This is a program that tests the placer geom manager
5 def do_motion(event):
6 app.button.place(x=event.x, y=event.y)
8 def dothis():
9 print 'calling me!'
11 def createWidgets(top):
12 # make a frame. Note that the widget is 200 x 200
13 # and the window containing is 400x400. We do this
14 # simply to show that this is possible. The rest of the
15 # area is inaccesssible.
16 f = Frame(top, width=200, height=200, background='green')
18 # place it so the upper left hand corner of
19 # the frame is in the upper left corner of
20 # the parent
21 f.place(relx=0.0, rely=0.0)
23 # now make a button
24 f.button = Button(f, foreground='red', text='amazing', command=dothis)
26 # and place it so that the nw corner is
27 # 1/2 way along the top X edge of its' parent
28 f.button.place(relx=0.5, rely=0.0, anchor=NW)
30 # allow the user to move the button SUIT-style.
31 f.bind('<Control-Shift-Motion>', do_motion)
33 return f
35 root = Tk()
36 app = createWidgets(root)
37 root.geometry("400x400")
38 root.maxsize(1000, 1000)
39 root.mainloop()