As another monk mentioned, you can create the widgets, place them into an array and then apply geometry management to the array elements, but the packer is really a particularly simple case — the other geometry managers end up needing more information, often unique to each widget.

As for -background => 'cyan', Tk offers an "options database" that uses something similar to app-defaults values and the options database should be used in preference to hardcoded color schemes. I am still learning how to use this and would appreciate any help other monks can provide for all here, but here are some bits from a program I am working on: (partially developed; partially tested; this is from the program I mentioned in POE::Filter for Tor control protocol)

use FindBin qw($Bin); # ... $poe_main_window->configure(-title => 'Tor Monitor'); $poe_main_window->appname('TorMon'); $poe_main_window->iconname('TorMon'); $poe_main_window->optionReadfile(File::Spec->catfile($Bin, 'app-defaul +ts'), 'startupFile'); $poe_main_window->configure (-background => $poe_main_window->optionGet('TorMon.background', 'Top'));

$Bin/app-defaults:

! Main TorMon.background: ghost white

So far, I have had no trouble applying defaults from an options file to all other widgets created (use "*" instead of "." in the options file if you want a setting to apply to a widget's descendants), but the main window itself just does not seem to "pick up" the settings from the options database. Lines 9 through 11 in the example is the workaround that I have been using. Maybe this is an interaction between Tk and POE?

You may also find the Name and -class options to be useful here; they are analogous to the id and class attributes in HTML if you consider the options database analogous to a stylesheet.

Lastly, setting the iconname on the main window is important — some window managers can crash while manipulating windows that do not set an icon name.


In reply to Re: Verbose Tk Code by jcb
in thread Verbose Tk Code by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.