Web | This Site

Python Basics
Python Advanced
Python Useful References
Python Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# Python - Tkinter place() Method

This geometry manager organizes widgets by placing them in a specific position in the parent widget.

## Syntax:

    widget.place( place_options )

Here is the list of possible options:

- anchor : The exact spot of widget other options refer to: may be N, E, S, W, NE, NW, SE, or SW, compass directions indicating the corners and sides of widget; default is NW (the upper left corner of widget)

- bordermode : INSIDE (the default) to indicate that other options refer to the parent's inside (ignoring the parent's border); OUTSIDE otherwise.

- height, width : Height and width in pixels.

- relheight, relwidth : Height and width as a float between 0.0 and 1.0, as a fraction of the height and width of the parent widget.

- relx, rely : Horizontal and vertical offset as a float between 0.0 and 1.0, as a fraction of the height and width of the parent widget.

- x, y : Horizontal and vertical offset in pixels.

## Example:

Try following example by moving cursor on different buttons:

    from Tkinter import *
    import tkMessageBox
    import Tkinter

    top = Tkinter.Tk()

    def helloCallBack():
       tkMessageBox.showinfo( "Hello Python", "Hello World")

    B = Tkinter.Button(top, text ="Hello", command = helloCallBack)

    B.pack()
    B.place(bordermode=OUTSIDE, height=100, width=100)
    top.mainloop()

This would produce following result:

Advertisement

Online Image Processing

Indian Baby Names