odd behaviour of Scale widget
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <OF72132884.5CCE48E5-ONC1256F8E.003E942D-C1256F8E.004B815E@philips.com> |
Hi all, I'm using a Scale widget in my application. Some of it's features can be configured during runtime (-from, -to, -resolution, -tickinterval). I noticed, that the Scale widget is buggy or at least odd behaving during this reconfigurations sometimes. For more see the little test script attached: (See attached file: testScale.pl) It creates 4 Scales. The topmost can be configured with the other 3 Scales. You can try a lot of things there yourself, but if you set e.g. -from to 1 (using the second slider) and then first increase, then decrease the tick interval (bottommost slider), you will notice, that it moves the slider, when the tickinterval is increased and also when it's decreased. But once the tick interval was at 4 or so and you want to change it back to 1, it doesn't work. You can see a lot more oddities when changing the resolution. Most of the problems I saw are there, when the from value is not 0. I don't want to describe all the things I tried out here - you can do yourself - especially playing with resolution and tickinterval. I just want to ask, who could debug this (as the essential part of the Scale.pm code is not Perl - so the user on the street can't do anything about it...). Nick, possibly you would have to have a look inside the Tk guts? Tcl/Tk (I tried 8.3.5 on Linux and 8.4.4 on Windows) behaves a bit better in this respect (see the tcl script included, that does the same as the perl script) (See attached file: testScale.tcl) At least changing the tickinterval doesn't influence the -from value. But like with Perl changing the resolution does change the -from value, if it doesn't fit the resolution grid started at 0. I think the resolution grid should always start at the -from value and the tickinterval too and it should have no influence on -from nor on the sliderposition. Thanks & regards, Gerhard Btw.: I'm using ActiveState Perl 5.6.1 build 635, but I also saw more or less the same behaviour on Perl 5.8.5 on Linux. --------------------------------------------------------------------------------------- Gerhard Petrowitsch Tel.: +49 8151 270 126 Philips Semiconductors Fax: +49 8151 270 200 Petersbrunnerstr. 17 Home Office: +49 821 9069 741 82319 Starnberg, Germany SERI: gerhard@DESTNSC1 --------------------------------------------------------------------------------------- Be like the ant. When the ant gets a mixture of sand and sugar, it selects only sugar; it neglects sand. See only good in others. Pay no attention to the bad. (Sathya Sai Baba) --------------------------------------------------------------------------------------------
testScale.pl
(application/octet-stream, 1.7 KB)
use Tk;
my $mw = MainWindow->new();
$mw->Label(-text => "Scale Under Test (SUT):")->pack(-anchor => 'w');
my $scale = $mw->Scale(-from => 0, -to => 20, -resolution => 1, -tickinterval => 1,
-orient => 'horizontal', -width => 8, -length => 300, -sliderlength => 16,
-variable => \$scaleVal,
-command => sub { print $scaleVal, "\n" })->pack();
my ($fromVal,$resVal,$tickVal)=(0,1,1);
$mw->Label(-text => "configure 'from' of SUT:")->pack(-anchor => 'w');
my $from = $mw->Scale(-from => 0, -to => 10, -resolution => 1, -tickinterval => 1,
-orient => 'horizontal', -width => 8, -length => 300, -sliderlength => 16,
-variable => \$fromVal,
-command => sub{$scale->configure(-from => $fromVal)})->pack();
$mw->Label(-text => "configure 'resolution' of SUT:")->pack(-anchor => 'w');
my $res = $mw->Scale(-from => 0, -to => 20, -resolution => 1, -tickinterval => 1,
-orient => 'horizontal', -width => 8, -length => 300, -sliderlength => 16,
-variable => \$resVal,
-command => sub{$scale->configure(-resolution => $resVal)})->pack();
$mw->Label(-text => "configure 'tickinterval' of SUT:")->pack(-anchor => 'w');
my $tick = $mw->Scale(-from => 0, -to => 20, -resolution => 1, -tickinterval => 1,
-orient => 'horizontal', -width => 8, -length => 300, -sliderlength => 16,
-variable => \$tickVal,
-command => sub{$scale->configure(-resolution => $tickVal)})->pack();
$mw->Button(-text => 'Exit', -command => sub { exit })->pack();
MainLoop;
testScale.tcl
(application/octet-stream, 1.3 KB) - not displayed