Your subs don't include anything that would alter the contents of $bits_10_9. The reason a reference works for the -textvariable piece is that it constantly checks that variable when doing screen-draw updates, but your assignment to $bit_10_9 is only checking those references once (when that statement is executed). You might try making a setbits() sub and using that as your callback. Example:
my $bit_10_9; #yes, this is a horrible abuse of globals
setbits( 0,0 );
my $bit_10_9_mb = $r2Frame->Menubutton(
-textvariable => \$bit_10_9,
-menuitems => [['command' => '01',
-command => sub{ setbits(0,1); }] ....
then
sub setbits
{
$bit[10] = shift || 0;
$bit[9] = shift || 0;
$bit_10_9 = $bit_10 . $bit_9;
}
Now normally I try to keep these sorts of globals to a minimum. But without going to OO data structures, it can be difficult to make this sort of data available to callbacks.
updateSheesh, I give the sloppiest answers sometimes. I've fixed this to apply more readily to the situation at hand.
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.