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

In reply to Tkx disabling/enabling menus by davide_c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.