blob: 992a8fc0d942dbab412849c83ea53db8a063f04f [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):
Guido van Rossum89cb67b1996-07-30 18:57:18 +00006 app.button.place(x=event.x, y=event.y)
Guido van Rossum35820f71994-10-07 09:55:26 +00007
8def dothis():
Collin Winter6f2df4d2007-07-17 20:59:35 +00009 print('calling me!')
Guido van Rossum35820f71994-10-07 09:55:26 +000010
11def 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.
Guido van Rossum89cb67b1996-07-30 18:57:18 +000016 f = Frame(top, width=200, height=200, background='green')
Guido van Rossum35820f71994-10-07 09:55:26 +000017
Tim Peters182b5ac2004-07-18 06:16:08 +000018 # place it so the upper left hand corner of
Guido van Rossum35820f71994-10-07 09:55:26 +000019 # the frame is in the upper left corner of
20 # the parent
Guido van Rossum89cb67b1996-07-30 18:57:18 +000021 f.place(relx=0.0, rely=0.0)
Guido van Rossum35820f71994-10-07 09:55:26 +000022
23 # now make a button
Guido van Rossum89cb67b1996-07-30 18:57:18 +000024 f.button = Button(f, foreground='red', text='amazing', command=dothis)
25
Tim Peters182b5ac2004-07-18 06:16:08 +000026 # and place it so that the nw corner is
Guido van Rossum35820f71994-10-07 09:55:26 +000027 # 1/2 way along the top X edge of its' parent
Guido van Rossum89cb67b1996-07-30 18:57:18 +000028 f.button.place(relx=0.5, rely=0.0, anchor=NW)
29
Guido van Rossum35820f71994-10-07 09:55:26 +000030 # allow the user to move the button SUIT-style.
31 f.bind('<Control-Shift-Motion>', do_motion)
32
33 return f
34
35root = Tk()
36app = createWidgets(root)
37root.geometry("400x400")
38root.maxsize(1000, 1000)
39root.mainloop()