sorry, zentara, but with my perl 5.8.8 this script first produces:

Bareword "Mainloop" not allowed while "strict subs" in use at ./Tkmenuentryconfigure.pl line 25

And even after i delete "use strict" i now get:

Useless use of a constant in void context at ./Tkmenuentryconfigure.pl line 25

I presume it did work for you at some point?

I also notice from Tk::Menu "BUGS At present it isn't possible to use the option database to specify values for the options to individual entries."

I have gotten around this by regenerating the menus with eliminated instead of "shaded" entries, but as always anyone who can successfully explain these mysteries better to me is very welcome to try ;)

On 02/12/2008 07:26:03 AM, zentara wrote:
-> On Mon, 11 Feb 2008 15:06:27 -0500, [EMAIL PROTECTED] (MK)
-> wrote:
->
-> >
-> >no matter where i use:
-> >
-> >$menu->entryconfigure(#,"disabled);
-> >
-> >i get:
-> >
-> >Can't locate object method "entryconfigure" via package
-> >"Tk::Menu::Cascade"
-> >
-> >unless i use it on a non-existent $menu, in which case i get:
-> >
-> >Can't call method "entryconfigure" on an undefined value
-> >
-> >Also, if i add a -command in a cascade(), i get no warnings or
-> >complaints but perl ignores the command and simply opens the menu.
-> I
-> >would like to call a command when a submenu is opened to determine
-> >which entries are available; surely this is possible?
->
-> Menu's are a complex nested structure and you need to delve into
-> it with cget, to get to the right menuitem.
->
-> Look at this example:
-> #!/usr/bin/perl
-> use warnings;
-> use strict;
-> use Tk;
->
-> my $count = 0;
->
-> my $mw = tkinit;
->
-> my $menubar = $mw->Menu(-type => 'menubar');
-> $mw->configure(-menu => $menubar);
->
-> my $menu = $menubar->cascade(-label => '~File');
-> $menu->command(-label => '~New');
-> $menu->command(-label => '~Open');
->
-> $mw->Button(
-> -text    => 'Push me and look at the menu',
-> -command => sub {
-> my $state = ($count++ & 1) ? 'normal' : 'disabled';
-> $menu->cget(-menu)->entryconfigure(2, -state => $state);
-> }
-> )->pack;
->
-> MainLoop;
-> __END__
->
->
-> zentara
->
->
->
-> --
-> I'm not really a human, but I play one on earth.
-> http://zentara.net/japh.html
->
-> --
-> To unsubscribe, e-mail: [EMAIL PROTECTED]
-> For additional commands, e-mail: [EMAIL PROTECTED]
-> http://learn.perl.org/
->
->
->
->
->



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to