All kinds of fun things happen when I dynamically rebuild my GUI in Tk. Here's an example: I have an array of recent commands (as per the Hash of Arrays example I shared the other day).
I display a button panel that has a button for each entry in the array which results from sorting that hash. Various factors cause the number of buttons to change.
...
for (my $i = 0; $i <= $#$rrecent; $i++)
{
$$rbut[$i] = $bpanelframe->Button( -text => $$rrecent[$i],
-fg => $clrfgbut,
+ -activeforeground => $clrfgbut,
-command => [\&fire, $$rrecent[$i], $_[0]] )
->pack( -side => 'top',
-anchor => 'n',
-fill => 'x',
-expand => 1 );}
}
...
$bpanelframe->pack( -side => 'top',
-anchor => 'n',
-fill => 'both',
-expand => 1 );
My problem is that $bpanelframe does not resize to accomodate the number of buttons inside it. Before calling this code the previous panel's $bpanelframe was ->packForget-ed. I either get blank space between the buttons or some buttons are neatly hidden underneath the frame packed below it.
The behaviour is inconsistent; sometimes it does resize, and other times it doesn't. Do I need to packForget all the way out to my outermost frames, or is there something else I'm missing? I've checked numerous tutorials on the Web and reconfiguring on the fly is not something that's discussed. It almost works right; that's the maddening part! :D
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.