in reply to Tk - how to alter appearance of Option Menu

Optionmenu is derived from Menubutton which has the -indicatoron option to show or hide that 'button'. Unfortunately, the author of Optionmenu decided to hardcode the state of -indicatoron to true in the Optionmenu Populate sub. That means you can not change the configuration as it is being constructed, (unless you build your own widget or override the Populate sub). You CAN however, easily change the state after it has been built.

use warnings; use strict; use Tk; my $mw = MainWindow->new(); my ( $var, $tvar ); my $opt = $mw->Optionmenu( -options => [ [ jan => 1 ], [ feb => 2 ], [ mar => 3 ], [ apr => 4 ], [ may => 5 ], [ jun => 6 ], [ jul => 7 ], [ aug => 8 ] ], -command => sub { print "got: ", shift, "\n" }, -variable => \$var, -textvariable => \$tvar, )->pack; # Now reconfigure the indicator button $opt->configure( -indicatoron => 0 ); MainLoop;

Replies are listed 'Best First'.
Re^2: Tk - how to alter appearance of Option Menu
by merrymonk (Hermit) on Jun 05, 2008 at 15:22 UTC
    Many thanks - it works just as I wanted it too!
    I suspect I would never have found it without your help.