For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > April 2004 > Change text of MenuButton









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Change text of MenuButton
Rainer Jung

2004-04-29, 6:47 am

Hello, Group.

I want to change the name of an Menubutton on Selection of the
submenu.
Here's a bit of code:

my $Menu = $MainWindow
-> Menubutton ( -text => 'Station' )
-> pack ( -side => 'right' );
my $Stations = { 1 => 'ARD', 2 => 'ZDF', 3 => 'Sat.1' };
my $Station;
foreach(keys %$Stations) {
$Menu -> radiobutton (
-label => $Stations->{$_},
-command \&switchStation,
-variable => \$Station,
-value => $_ );
}

sub switchStation {
...
}

Now, can someone tell me, how i can change the Text ('Station') from
the Menubutton to the selected Station-Name (f.e. 'ARD' or 'ZDF')
inside the switchStation procedure?
I Tried:
$Menu -> entryconfigure( -label => $Stations->{$Station} );
But got:
Tk::Error: bad menu entry index "-label" at Tk.pm line 228.
Tk callback for .frame.menubutton1.menu
[\&main::switchStation]
(menu invoke)

Thanks, Rainer
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com