Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Tk - laying out your GUI with frames, pack and grid

Using Tk (in Tcl or in Perl), you create a number of components that you want to display as part of your GUI (Graphic User Interface) using commands such as button, label and canvas. These components are known as widgets.

Once you've created your widgets, you need to use a geometry manager to tell the program how to display them in relation to each other - and there are three such geometry managers.

pack allows you to place your widgets in a row or column

grid allows you to place your widgets in a matrix

place is rarely used, and gives you the ability to place widgets by pixel or by the proportion of the way across the window that you want them to appear.

Pack, grid and place don't on their own provide you with the full flexibility to lay out more complex windows. For a complex layout, you'll split the parent window into a series of frames which you will pack or grid, and then you'll pack or grid the individual widgets into the frames. If necessary, you can nest frames several layers deep.

If you're a designer laying out your GUI, where should you start? With a sketch on a sheet of paper (or a whiteboard). Look to see if the WHOLE layout can be achieved by using a single pack or grid ... if not, look for places where you can draw a line between widgets RIGHT ACROSS the window. These lines are the first level of splitting you GUI down into frames.

If you can draw lines RIGHT ACROSS, both horizontally and vertically, then you'll use the grid geometry manager for your root window. If you can draw ONLY horizontal or vertical lines, then you'll use pack.

Repeat the design process, frames within frames, until each of your remaining subframes is a simple grid or pack in its own right, or is a single widget.
(written 2006-06-30)

Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
T220 - Tcl/Tk - Frames and Other Topics
  [1335] Expanding a grid - Tcl/Tk - (2007-09-07)
  [1471] Cliff Lift simulator- Lynton to Lynmouth - in Tcl/Tk - (2007-12-14)
  [4459] Managing the window size (and layout) in Tcl/Tk - (2015-03-12)

T218 - Tcl/Tk - Geometry Managers
  [212] Tcl/Tk (wish) Grid layout example - (2005-02-12)
  [445] Sticky news - (2005-09-15)
  [1340] Tk locks up - 100% c.p.u. on a simple program (Tcl, Perl, Python) - (2007-09-09)
  [1470] fill and expand on Tcl/Tk pack command - (2007-12-13)

Back to
First Light, Bootle Docks, Liverpool
Previous and next
Horse's mouth home
Forward to
New - Conditional expressions in Python 2.5
Some other Articles
Strange housewarming
Shadow Transport Minister to visit Melksham
Hot answers in PHP
New - Conditional expressions in Python 2.5
Tk - laying out your GUI with frames, pack and grid
First Light, Bootle Docks, Liverpool
Running external processes in Tcl and Tcl/Tk
Which way to turn?
Good follow up ... my thanks
Converting between Hex and Decimal in Tcl
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page

This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/787_Tk-l ... -grid.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb