home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Demo / tkinter / matt / placer-simple.py < prev    next >
Text File  |  1996-07-30  |  1KB  |  41 lines

  1. from Tkinter import *
  2.  
  3. # This is a program that tests the placer geom manager
  4.  
  5. def do_motion(event):
  6.     app.button.place(x=event.x, y=event.y)
  7.  
  8. def dothis():
  9.     print 'calling me!'
  10.  
  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')
  17.  
  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)
  22.  
  23.     # now make a button
  24.     f.button = Button(f, foreground='red', text='amazing', command=dothis)
  25.  
  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)
  29.  
  30.     # allow the user to move the button SUIT-style.
  31.     f.bind('<Control-Shift-Motion>', do_motion)
  32.  
  33.     return f
  34.  
  35. root = Tk()
  36. app = createWidgets(root)
  37. root.geometry("400x400")
  38. root.maxsize(1000, 1000)
  39. root.mainloop()
  40.  
  41.