RE: Strange Perl/Tk action
by Geoff Horsnell other posts by this author
Oct 26 2009 4:09AM messages near this date
view in the new Beta List Site
RE: Strange Perl/Tk action
|
Poll: Which editor(s) or IDE(s) are you using for Perl development?
Many thanks. I have tried your suggestion and it seems to do the trick! And,
as you say, it also loses the "flicker".
Once again, many thanks
Geoff
-----Original Message-----
From: Jack [mailto:goodcall1@[...].com]
Sent: Monday, October 26, 2009 3:44 AM
To: 'Geoff Horsnell'; perl-win32-users@[...].com
Subject: RE: Strange Perl/Tk action
Ok. I get it now. First off - sorry for the top post. It's just the way my
mail works.
I don't see the canvas resize on Vista, however I do see it flicker. I don't
doubt that it resizes though, I just cannot reproduce it. I guess the main
question I have is "why are you rebuilding the entire menu just to disable
an entry?". Instead you should just use the entryconfigure method and target
the entry you wish to disable.
Here is one way of doing that (fully working code - just cut, paste and
run):
#######################
use Tk;
use strict;
my $mw=tkinit;
$mw-> Canvas->pack;
create_all_menus_only_once();
MainLoop;
sub create_all_menus_only_once {
my $menub = $mw-> Menu(-type => "menubar");
$mw-> configure (-menu => $menub);
my $submenu = create_menu1($menub);
$menub-> cascade(
-label => "Edit",
-underline => 0,
-tearoff => 0,
-menu=> $submenu);
}
sub create_menu1 {
my $mainmenu = shift;
my $menu1 = $mainmenu-> Menu(-tearoff=>0);
#First entry
$menu1-> command(-label => 'A Switch to B',
-command=> [\&switch,$menu1,'A']);
#Second entry
$menu1-> command(-label => 'B Switch to A',
-command=> [\&switch,$menu1,'B'], -state=>'disabled');
return ($menu1);
}
sub switch {
my ($m,$val) = @_;
if ($val eq 'A') {
$m-> entryconfigure(0,-state=>'disabled');
$m-> entryconfigure(1,-state=>'normal');
}
elsif ($val eq 'B') {
$m-> entryconfigure(0,-state=>'normal');
$m-> entryconfigure(1,-state=>'disabled');
}
}
__END__
#######################
There are "so" many ways to create and manipulate menus - that I could not
cover all the scenarios. In this method, I created the submenu before
creating the "Edit" cascade. This will allow you to use the menu reference
to adjust the entries as you see fit.
There is "no flicker" with this code - so I will guess that it will solve
your resizing issue.
HTH
Jack
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Geoff Horsnell
Jack
Geoff Horsnell
Brian Raven
Jack
Geoff Horsnell
|