(py-indent-right, py-outdent-left): new commands, bound to C-c C-r and
[python/dscho.git] / Demo / tkinter / matt / packer-and-placer-together.py
blob64b38216a66650067c38440f25b728369ba74860
1 from Tkinter import *
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
7 def do_motion(event):
8 app.button.place({'x' : event.x,
9 'y' : event.y})
11 def dothis():
12 print 'calling me!'
14 def 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'})
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})
29 # now make a button
30 f.button = Button(f, {'fg' : 'red',
31 'text' : 'amazing',
32 'command' : dothis})
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'})
40 # allow the user to move the button SUIT-style.
41 f.bind('<Control-Shift-Motion>', do_motion)
43 return f
45 root = Tk()
46 app = createWidgets(root)
47 root.geometry("400x400")
48 root.maxsize(1000, 1000)
49 root.mainloop()