Tuesday, January 5, 2016

Python Tkinter layout managers

As I am becoming better at using Tkinter, I am gaining a better appreciation for how to use the different layout managers. It turns out that there are three of them, of which I currently most like to use "pack" and "grid" (the third being "absolute", which is both less portable and less elegant than the other two). Here are some bookmarks to the information that I'm making the most use of.

First, some good general tutorial pages:
http://zetcode.com/gui/tkinter/layout/

About pack():

What I have learned is that it's a very quick method of building up display panels using a paradigm of block stacking. You have to define objects, then you place objects within objects in stacks. If you don't use a "side" argument, whatever object you pack gets stacked under the previous objects. A string of pack() commands with "side" arguments get placed next to each other at the same level. Objects can be stretched to touch sides on one or both axes of the object they've been packed into. It's nuts primitive but so easy and quick.

Here is a description of the function with its parameters and a couple of go-to examples:

http://effbot.org/tkinterbook/pack.htm


some of the same examples as in the above link but more nicely presented:

http://www.python-course.eu/tkinter_layout_management.php


grid() is like doing HTML tables, very intuitive and handles resizing well.