Background: I've got an array (@bit) that represents a bit field. I would like to
have a menubutton whose text is the concatenation of elements 9 and 10 of this
array. I want the menubutton's text to update whenever I change the values of
elements 9 and 10. So the button might display 01, and then after changing bits
9 and 10 it would display 11, or 10, etc.
Here is a snippet of the code I have right now:
(I've tried a couple of variations with no luck)
$bit_10 = \$bit[10];
$bit_9 = \$bit[9];
$bit_10_9 = $$bit_10 . $$bit_9;
$bit_10_9_mb = $r2Frame->Menubutton(
-textvariable => \$bit_10_9,
-menuitems => [['command' => "00",
-command => sub {$bit[10]
+= 0; $bit[9] = 0;}],
['command' => "01",
-command => sub {$bit[10]
+= 0; $bit[9] = 1;}],
['command' => "10",
-command => sub {$bit[10]
+= 1; $bit[9] = 0;}],
['command' => "11",
-command => sub {$bit[10]
+= 1; $bit[9] = 1;}]],
-background => "black",
-foreground => "white",
-tearoff => 0,
-relief => "groove",
)->pack(-side => "left", "-after" => $bit_
+11_entry);
Right now the code does indeed display the concatenation of the bits, but the button's text is never updated
from its original value whenever I change the values of bits 9 and 10.
I'm stuck! I have tried this a couple of different ways (with and w/o references) and can't get it to work.
Any help would be greatly appreciated.
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.