Python tkinter_Geometry Manager/pack()/place()














































Python tkinter_Geometry Manager/pack()/place()



pack(): pack() geometry function organizes widgets in blocks before placing them in the parent widget. It uses the options fill , expand and side.

Fill - It determines if the widget keeps the minimal space needed or takes up any extra space allocated to it. Attributes: NONE (default), X (fill horizontally), Y (fill vertically), or BOTH (fill both horizontally and vertically).

Expand - When it set to YES, the widget expands to fill any space not used in widget's parent.

Attributes: YES, NO.

Side Determines which side of the widget's parent it packs to.

Attributes - TOP (default), BOTTOM, LEFT, or RIGHT.

Example- 


output:


place(): This manager used to organize widgets by placing them in the specific position in the parent widgets. This geometry manager provides anchor , Bordermode ,height , width, relheight, relwidth, relx , rely ,x, y.
Anchor - It anchored the widget and  options are compass directions: N, E, S, W, NE, NW, SE, or SW, which relate to the sides and corners of the parent widget. The default is NW (the upper left corner of widget).
Bordermode - It has two options INSIDE or OUTSIDE.
Height - It specify the height of a widget in pixels.

Width - It specify the width of a widget in pixels.

RelheightHeight as a float between 0.0 and 1.0, as a fraction of the height of the parent widget.

RelwidthWidth as a float between 0.0 and 1.0, as a fraction of the width of the parent widget.

Relx-Horizontal offset as a float between 0.0 and 1.0, as a fraction of the width of the parent widget.

Rely-Vertical offset as a float between 0.0 and 1.0, as a fraction of the height of the parent widget.

X- Horizontal offset in pixels.

Y-Vertical offset in pixels.

Example-


output:


Comments