sábado, 4 de noviembre de 2017

Different Layout Managers in Python’s TKInter GUI package Pack Layout Manager Grid Layout Manager Place Layout Manager

Different Layout Managers in Python’s TKInter GUI package

 

http://programminginpython.com/layout-managers-python-gui-pack-grid-place/ 

 

Pack Manager

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.
Use side option to align them horizontally.
Expand operation to take up the full height until the content ends. We use listbox widget to fill up space.

Pack Manager Example:

Python GUI Layout Managers - programminginpython.com
Python GUI Layout Managers – programminginpython.com

Grid Manager

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.
Python GUI Layout Managers - programminginpython.com
Python GUI Layout Managers – programminginpython.com

Place Manager

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.
Python GUI Layout Managers - programminginpython.com
Python GUI Layout Managers – programminginpython.com
That is all about Python GUI Layout managers pack, grid, and place.
Please feel free to look at my other posts on Python GUI programs.

No hay comentarios:

Publicar un comentario