0% found this document useful (0 votes)
71 views

Python - Tkinter Place Method

The place() geometry manager in Tkinter allows widgets to be placed at specific pixel positions within their parent widget. It accepts options like anchor, bordermode, height, width, relheight, relwidth, x, and y to define the exact position and size of the widget. In the example code, a Button widget is placed with a height and width of 100 pixels each outside the borders of its parent window.

Uploaded by

Vizual Ta'lim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views

Python - Tkinter Place Method

The place() geometry manager in Tkinter allows widgets to be placed at specific pixel positions within their parent widget. It accepts options like anchor, bordermode, height, width, relheight, relwidth, x, and y to define the exact position and size of the widget. In the example code, a Button widget is placed with a height and width of 100 pixels each outside the borders of its parent window.

Uploaded by

Vizual Ta'lim
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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 the 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()
When the above code is executed, it produces the following result −

You might also like