in reply to Perl/TK: enabling a disable menu item

sorry posted the wrong menu code.
Please refer to the following code.
my $file_menu = $menubar->Menubutton(-text => "File", -activebackground => 'blue', -activeforeground => 'white', -tearoff => 0, -menuitems => [ [Button => '~Sele +ct', -command => \&select_file , -accelerator => '<Ctrl-s>'], [Button => "~Edit +",-state => 'disabled', -command => \&edit_file , -accelerator => '<Ctrl-e>' ], [Button => '~Gene +rate XML', -state => 'disabled',-command => \&gen_xml , -accel erator => '<Ctrl-x>'], ["separator" => " + "], [Button => "Exit +", -command => sub {exit 0;} , -accelerator => 'ESC'] ])->pack(-side => + 'left');

Replies are listed 'Best First'.
Re: Re: Perl/TK: enabling a disable menu item
by bobn (Chaplain) on Jul 30, 2003 at 07:57 UTC

    After staggering through Mastering Perl/Tk, I come up with this, which seems to work:

    my $fm = $menubar->entrycget('File', -menu); # *after* creating the File Menubutton in the $menubar sub select_file { $fm->entryconfigure('Edit', -state=>'normal') }
    --Bob Niederman, http://bob-n.com