RE: Strange Perl/Tk action
by Geoff Horsnell other posts by this author
Oct 24 2009 4:38PM messages near this date
view in the new Beta List Site
RE: Strange Perl/Tk action
|
RE: Strange Perl/Tk action
Unfortunately, it would be rather a lot of code. I will try to describe the
action with example segments.
...
sub create_all_menus {
$mode = "A";
$menub = $tl-> Menu(-type => "menubar");
$tl-> configure (-menu => $menub);
$widget1 = menub-> cascade(-label => "Edit, -underline => 0, -tearoff =>
0);
$widget-> pack(-side => "top", -anchor => "nw");
&create_menu1 ($widget1);
...
}
sub create_menu1 {
my $widget = shift;
$state = "disabled";
if ($mode eq "A") {
$widget-> command(-label => "B", -underline => 0, -command =>
\&switchToB);
$widget-> command(-label => "A", -underline => 0, -command =>
\&switchToA, -state => $state);
} else {
$widget-> command(-label => "B", -underline => 0, -command =>
\&switchToB, -state => $state);
$widget-> command(-label => "A", -underline => 0, -command =>
\&switchToA);
}
}
...
sub switchToA {
$mode = "A";
&create_all_menus (...); # repaint all menu buttons
}
Sub switchToB {
$mode = "B";
&create_all_menus (...); # repaint all menu buttons
}
After calling the "create_all_menus" from the main program, option "A" is
greyed out and option "B" is active. When "B" is selected for the first
time, option "B" is then greyed out and option "A" is active. At the same
time, the height of the "canvas" window containing these menu buttons is
reduced by about 0.2 cm. Subsequent selection of the "A" or "B" menu option
(whichever is currently active) has no further effect on the size of the
window.
I hope this makes better sense.
TIA
Geoff
-----Original Message-----
From: Jack [mailto:goodcall1@[...].com]
Sent: Saturday, October 24, 2009 10:51 PM
To: 'Geoff Horsnell'; perl-win32-users@[...].com
Subject: RE: Strange Perl/Tk action
It's hard to follow your description. Can you upload some sample code that
shows the problem?
"Shrinkage is always bad" ;)
Jack
________________________________
From: perl-win32-users-bounces@[...].com
[mailto:perl-win32-users-bounces@[...].com] On Behalf Of
Geoff Horsnell
Sent: October-24-09 10:05 AM
To: perl-win32-users@[...].com
Subject: Strange Perl/Tk action
I have created a GUI using the Tk "canvas" widget that contains a menu list
with two mutually exclusive menu items - say "A" and "B". When "A" is
selected, "B" should be disabled (greyed out) and vice versa. Therefore,
when the currently active option is selected, the menu list needs to be
repainted switching the active and disabled items. However, the first time
that this happens, the height of the canvas window shrinks - by about the
height of the menu tab. The height of the window remains unchanged for all
subsequent menu actions. I have printed out the variable containing the
nominated height of the window before and after making the selection and it
does not change. I can compensate for this action by making the original
window height slightly larger in the first place. However, I would rather
that the shrinkage did not happen at all. Has anyone seen this happen for
themselves and does anyone know how to prevent the window from shrinking in
the first place?
Any suggestions would be most welcome.
Many thanks
Geoff
_______________________________________________
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
|