pack is one of the oldest and most used layout manager
in Python’s TKInter package. It is very easy to style and place the
widgets in an app using this pack() manager. When you use this pack() method on a widget, you don’t need to explicitly specify the position of that widget, pack automatically places the widget in window based upon the space available in the window.
You can use pack when your layout only consists of a group of items
all aligned horizontally or vertically, mostly in case of a navigation
menu or something like that.
This pack() has 3 options to use they are: fill, expand, and side. I will create a simple example to demonstrate this pack manager.
I will use fill option to align three labels vertically.
grid is one of the most flexible layout manager out of
the three GUI layout managers in python. It was introduced as an
alternative to pack. Grid allows you to position the elements in rows and columns which give you more flexibility to your widgets.
I will create a simple 2×2 table like structure using grid’s rows and column way.
place is the most complex manager out of the 3 managers. It uses absolute positioning, when you choose place
as your layout manager, then you need to specify the widgets
positioning using x and y coordinates, When using this layout manager
the size and position of the widgets do not change while resizing the
window.
I will create a simple 4 lables which I will position based upon x and y coordinates.
No hay comentarios:
Publicar un comentario