in reply to Tk Optionmenu - how to set the default selection
#!/usr/bin/perl use warnings; use strict; use Tk; my @hrs = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"); my $mw = new MainWindow(); my $menu = $mw->Optionmenu( -options => \@hrs, -textvariable => \$hrs[0] )->pack(); $mw->Button(-text=>'Shift',-command => sub{ push (@hrs, shift(@hrs)); $menu->configure(-options => \@hrs, -textvariable => \$hrs[0] ); $mw->update; })->pack(); #start up at desired value my $desired = 3; push (@hrs, shift(@hrs)) until $hrs[0] == 3; $menu->configure(-options => \@hrs, -textvariable => \$hrs[0] ); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tk Optionmenu - how to set the default selection
by Minok (Novice) on Feb 10, 2009 at 18:29 UTC |