summaryrefslogtreecommitdiffstats
path: root/Demo/tkinter/matt/placer-simple.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-10-07 09:55:26 (GMT)
committerGuido van Rossum <guido@python.org>1994-10-07 09:55:26 (GMT)
commit35820f77e41a8a41a695e08c041eed5e2e2ff3ef (patch)
tree2bf45f05d7530067911726bf9a3e56b453d49db5 /Demo/tkinter/matt/placer-simple.py
parent884657af490e79e8e4a3038b439af9713cb64bc8 (diff)
downloadcpython-35820f77e41a8a41a695e08c041eed5e2e2ff3ef.zip
cpython-35820f77e41a8a41a695e08c041eed5e2e2ff3ef.tar.gz
cpython-35820f77e41a8a41a695e08c041eed5e2e2ff3ef.tar.bz2
Matt's examples
Diffstat (limited to 'Demo/tkinter/matt/placer-simple.py')
-rw-r--r--Demo/tkinter/matt/placer-simple.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/Demo/tkinter/matt/placer-simple.py b/Demo/tkinter/matt/placer-simple.py
new file mode 100644
index 0000000..724cb97
--- /dev/null
+++ b/Demo/tkinter/matt/placer-simple.py
@@ -0,0 +1,48 @@
+from Tkinter import *
+
+# This is a program that tests the placer geom manager
+
+def do_motion(event):
+ app.button.place({'x' : event.x,
+ 'y' : event.y})
+
+def dothis():
+ print 'calling me!'
+
+def createWidgets(top):
+ # make a frame. Note that the widget is 200 x 200
+ # and the window containing is 400x400. We do this
+ # simply to show that this is possible. The rest of the
+ # area is inaccesssible.
+ f = Frame(top, {'width' : '200',
+ 'height' : '200',
+ 'bg' : 'green'})
+
+ # place it so the upper left hand corner of
+ # the frame is in the upper left corner of
+ # the parent
+ f.place({'relx' : '0.0',
+ 'rely' : '0.0'})
+
+ # now make a button
+ f.button = Button(f, {'fg' : 'red',
+ 'text' : 'amazing',
+ 'command' : dothis})
+
+ # and place it so that the nw corner is
+ # 1/2 way along the top X edge of its' parent
+ f.button.place({'relx' : '0.5',
+ 'rely' : '0.0',
+ 'anchor' : 'nw'})
+
+ # allow the user to move the button SUIT-style.
+ f.bind('<Control-Shift-Motion>', do_motion)
+
+ return f
+
+root = Tk()
+app = createWidgets(root)
+root.geometry("400x400")
+root.maxsize(1000, 1000)
+root.mainloop()
+