Copyright (C) 2000-2012 |
Manpages OPTIONMENUSection: User Contributed Perl Documentation (1)Updated: 2000-04-18 Index Return to Main Contents NAMETk::Optionmenu - Let the user select one of some predefined options valuesSYNOPSISuse Optionmenu; $opt = $w->Optionmenu( -options => REFERENCE_to_OPTIONLIST, -command => CALLBACK, -variable => SCALAR_REF, ); $opt->addOptions( OPTIONLIST ); # OPTION LIST is # a) $val1, $val2, $val3,... # b) [ $lab1=>$val1], [$lab2=>val2], ... ] # c) combination of a) and b), e.g., # val1, [$lab2=>val2], val3, val4, [...], ... DESCRIPTIONThe Optionmenu widget allows the user chose between a given set of options.If the user should be able to change the available option have a look at Tk::BrowseEntry. OPTIONS
METHODSEXAMPLEuse Tk; my $mw = MainWindow->new(); my $var; my $opt = $mw->Optionmenu( -options => [qw(jan feb mar apr)], -command => sub { print "got: ", shift, "\n" }, -variable => \$var, )->pack; $opt->addOptions([may=>5],[jun=>6],[jul=>7],[aug=>8]); $mw->Label(-textvariable=>\$var, -relief=>'groove')->pack; $mw->Button(-text=>'Exit', -command=>sub{$mw->destroy})->pack; MainLoop; SEE ALSOTk::Menubutton, Tk::BrowseEntry
IndexThis document was created by man2html, using the manual pages. Time: 02:25:41 GMT, April 20, 2024 |