davide_c has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I'm in the process of porting an old application from perl/tk to tkx.
I'm having problems trying to change the state of a menu entry in the application menu.
I thought I should use configure(-state=>'disabled') or 'normal', but it seems I can't get the right pathname to the item I need.

Here is a quick mockup. The exact same code works for enabling/disabling buttons.
#!/usr/bin/perl use strict; use warnings; use Tkx; my $mw = Tkx::widget->new("."); my $menu = $mw->new_menu; my $M_file = $menu->new_menu( -name => "file", -tearoff => 0, ); my $UUU=$menu->add_cascade( -label => "File", -underline => 0, -menu => $M_file, -state=>'normal', ); $M_file->add_command( -label => "New", -underline => 0, -command => \&new, ); $M_file->add_command( -label => "Exit", -underline => 1, -command => [\&Tkx::destroy, $mw], ); my $help = $menu->new_menu( -name => "help", -tearoff => 0, ); $menu->add_cascade( -label => "Help", -underline => 0, -menu => $help, ); $help->add_command( -label => "\uManual", -command => \&show_manual, ); $mw->configure(-menu => $menu); my $button_test= $mw->new_ttk__button(-text => "test", -command => \&t +st1); $button_test->g_grid(-column => 0, -row => 0, -sticky => "ew"); &Tkx::MainLoop(); exit; sub tst1 { my $st = $UUU->cget(-state); $st eq 'normal' ? $UUU->configure(-state =>'disabled') : $UUU->confi +gure(-state =>'normal'); }
according to
http://docs.activestate.com/activetcl/8.4/tcl/TkCmd/menu.htm
this should be the procedure (in fact, one can set the menu as normal or disabled during creation). But I can't understand how to change it.

any pointers?

thanks

Replies are listed 'Best First'.
Re: Tkx disabling/enabling menus (wot)
by Anonymous Monk on May 21, 2015 at 00:33 UTC