| |||||||||||
| |||||||||||
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 06:37:05) Associated topics are indexed under T218 - Tcl/Tk - Geometry ManagersT220 - Tcl/Tk - Frames and Other Topics
Some other Articles
Strange housewarmingShadow 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 1638 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 at 50 posts per pageThis 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). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||