[Tutor] Coordinates of a frame

Michael P. Reilly arcege@shore.net
Thu, 8 Mar 2001 11:49:32 -0500 (EST)


[Charset iso-8859-1 unsupported, filtering to ASCII...]
> How can i define where a frame is created (X,Y Coordinates is integers)?
> 
> Thanks for your help!
> J_rg

Do you mean with Tkinter?  I'll assume so.

You would use the place() methods (instead of pack()).  With this
geometry manager, you can position widgets absolutely, or relative to
another widget (for example, centered in another widget).

>>> from Tkinter import *
>>> root =Tk()
>>> pane = Frame(root)
>>> Label(pane, text="Pane Title", bg="red").pack()
>>> b = Button(pane, width=12, height=12, text="Go!")
>>> # place the top-right corner (NE) at (-2,2) within the frame
>>> b.place(relx=1,x=-2,y=2, anchor=NE)
>>> pane.pack()

You'll see the red in the background from the Label widget.  The
Button is placed over it.

>>> b.lower()  # you'll see the "Pane Title" appear
>>> b.lift()   # you'll see the Button come back to the foreground

You might want to look at Fredrik Lundh's "An Introduction to Tkinter"
<URL: http://www.pythonware.com/library/tkinter/introduction/> and
Grayson's "Python and Tkinter Programming" book.

  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Manager  | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------