in reply to Updating concatenated text on a Menubutton

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.

Replies are listed 'Best First'.
Re: (ichimunki) Re: Updating concatenated text on a Menubutton
by Fastolfe (Vicar) on Nov 27, 2001 at 02:27 UTC

    I'm not familiar with this GUI system, but does the subroutine in the -command argument get passed anything in @_? Maybe that can be passed into setbits() where the function can manipulate the menu's text directly, instead of through these global references.

    Just some idle thoughts... I also don't care for the intermediate variables $bit_9 and $bit_10. He should probably just be using @bit[9,10] directly.