in reply to How do I select a Tk menu radiobutton without deselecting another?
From the docs:
Whenever a particular entry becomes selected it stores a particular value into a particular global variable (as determined by the -value and -variable options for the entry).You need variables for each group:
use strict; use warnings; use Tk; use subs qw/menubar_etal/; my ($g1,$g2); my $mw = MainWindow->new; $mw->configure(-menu => my $menubar = $mw->Menu(-menuitems => menubar_ +etal)); MainLoop; sub menubar_etal { [ map ['cascade', $_->[0], -menuitems => $_->[1]], ['~Preference', [ [qw/cascade Cascade1 -tearoff 0 -menuitems/ => [ map ['radiobutton', $_, -variable => \$g1],qw/1 2 3 4/, + ], ], [qw/cascade Cascade2 -tearoff 0 -menuitems/ => [ map ['radiobutton', $_, -variable => \$g2],qw/A B C D/, + ], ], ], ], ]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I select a Tk menu radiobutton without deselecting another?
by Xiaoyu (Initiate) on Oct 11, 2011 at 04:34 UTC |