optionmenu(3)

NAME

Tk::Optionmenu - Let the user select one of some prede
fined options values

SYNOPSIS

use 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, [...], ...

DESCRIPTION

The 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

-options
(Re)sets the list of options presented.
-command
Defines the callback that is invokes when a new option
is selected.
-variable
Reference to a scalar that contains the current value
of the selected option.

METHODS

addOptions
Adds OPTION_LIST to the already available options.

EXAMPLE

use Tk;
my $mw = MainWindow->new();

my $var;
my $opt = $mw->Optionmenu(
-options => [qw(jan feb mar apr)],
-command => sub { print "got: ", shift, "0
},
-variable => ar,
)->pack;
$opt->addOptions([may=>5],[jun=>6],[jul=>7],[aug=>8]);
$mw->Label(-textvariable=>ar, -re
lief=>'groove')->pack;
$mw->Button(-text=>'Exit', -command=>sub{$mw->de
stroy})->pack;
MainLoop;

SEE ALSO

Tk::Menubutton, Tk::BrowseEntry
Copyright © 2010-2025 Platon Technologies, s.r.o.           Index | Man stránky | tLDP | Dokumenty | Utilitky | O projekte
Design by styleshout