shortyfw06 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to understand how the ->grid options work when organizing frames in the main window. Can you please suggest a good reference on this topic? The primary issue is creating four equally sized frames within a main window. Thank you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TK Geometry Management
by zentara (Cardinal) on Mar 16, 2012 at 16:28 UTC | |
To be honest, although grid() seems easier and more intuitive to a new programmer, pack() is easier to use, especially when you want to easily handle window resizing by the user. The primary issue is creating four equally sized frames within a main window If that is the primary issue, look at how easy pack can do it. And remember, frames only get any size by the size of the widgets they contain. No widgets, no size for the frame. Notice in pack, the -expand and -fill options, which tell the pack() geometry manager how to handle resizes. Your can have just x or y filling with -fill=>'x" or -fill=> "y". I hardly ever resort to using grid(), but I seem to recall it's resizing is a bit more complex to handle.
I'm not really a human, but I play one on earth. Old Perl Programmer Haiku ................... flash japh | [reply] [d/l] |
|
Re: TK Geometry Management
by kcott (Archbishop) on Mar 16, 2012 at 16:47 UTC | |
In my opinion, the best reference work is still the book: Mastering Perl/Tk. Its predecessor, Learning Perl/Tk, coming a close second. Both of these books devote an entire chapter to geometry management. In my experience, it's best to use the same geometry manager within a Frame; use Frames to embed a different geometry manager. For instance, several Frames may be pack()ed; any of those Frame widgets may contain a set of widgets using a different geometry manager - mixing geometry managers within Frames typically results in tears. To illustrate further, code like this is generally fine:
While
is typically problematical. The documentation for individual geometry managers is linked from: CPAN - Tk. Update: I had 7 instances of mismatched brackets: s/{...)/(...)/ - thanks moritz; s/.-/->/; s/=/->/ -- Ken | [reply] [d/l] [select] |
|
Re: TK Geometry Management
by thundergnat (Deacon) on Mar 16, 2012 at 16:59 UTC | |
Here's another example for comparison. (with some added silliness.) The frames grow/shrink when you resize the main window.
| [reply] [d/l] |