in reply to optionmenu configure problem in perl tk

It doesn't seem that Optionmenu objects have support for the configure option. running your code while the lines $opt->configure(...) and $opt1->configure(...) are commented out yields the Tk widget.

Check Optionmenu Configuration Options...


Excellence is an Endeavor of Persistence. A Year-Old Monk :D .

Replies are listed 'Best First'.
Re^2: optionmenu configure problem in perl tk
by kcott (Archbishop) on Nov 08, 2010 at 13:21 UTC

    Tk::Optionmenu is derived from Tk::Menubutton and probably has support for configuring most, if not all, of its options.

    The documentation is somewhat brief and possibly ambiguous in terms of making a clear distinction between options of the widget (e.g. $w->configure($option => $val); and options of the menu (e.g. $w->addOptions([@new_options]);).

    Try this example code:

    #!perl use 5.12.0; use warnings; use Tk; use Tk::Optionmenu; my $mw = MainWindow->new(); my $om = $mw->Optionmenu( -options => [qw{Zero One Two Three}], )->pack(); my $state = 0; my @states = qw{normal disabled}; $mw->Button(-text => q{Toggle State}, -command => sub { $state ^= 1; $om->configure(-state => $states[$state]); })->pack(); $mw->Button(-text => q{Exit}, -command => sub { exit })->pack(); MainLoop;

    -- Ken