For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > January 2005 > odd behaviour of Scale widget









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author odd behaviour of Scale widget
gerhard.petrowitsch@philips.com

2005-01-19, 4:20 pm

-- 0__=4EBBE51DDFAD12BD8f9e8a93df938690918c
4EBBE51DDFAD12BD
Content-type: text/plain; charset=US-ASCII

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)
--------------------------------------------------------------------------------------------
-- 0__=4EBBE51DDFAD12BD8f9e8a93df938690918c
4EBBE51DDFAD12BD
Content-type: application/octet-stream;
name="testScale.pl"
Content-Disposition: attachment; filename="testScale.pl"
Content-transfer-encoding: base64

dXNlIFRrOw0KDQpteSAkbXcgPSBNYWluV2luZG93
LT5uZXcoKTsNCiRtdy0+TGFiZWwoLXRleHQg
PT4gIlNjYWxlIFVuZGVyIFRlc3QgKFNVVCk6Iikt
PnBhY2soLWFuY2hvciA9PiAndycpOw0KbXkg
JHNjYWxlID0gJG13LT5TY2FsZSgtZnJvbSA9PiAw
LCAtdG8gPT4gMjAsIC1yZXNvbHV0aW9uID0+
IDEsIC10aWNraW50ZXJ2YWwgPT4gMSwNCiAgICAg
ICAgICAgICAgICAgICAgICAgLW9yaWVudCA9
PiAnaG9yaXpvbnRhbCcsIC13aWR0aCA9PiA4LCAt
bGVuZ3RoID0+IDMwMCwgLXNsaWRlcmxlbmd0
aCA9PiAxNiwNCiAgICAgICAgICAgICAgICAgICAg
ICAgLXZhcmlhYmxlID0+IFwkc2NhbGVWYWws
DQogICAgICAgICAgICAgICAgICAgICAgIC1jb21t
YW5kID0+IHN1YiB7IHByaW50ICRzY2FsZVZh
bCwgIlxuIiB9KS0+cGFjaygpOw0KbXkgKCRmcm9t
VmFsLCRyZXNWYWwsJHRpY2tWYWwpPSgwLDEs
MSk7DQokbXctPkxhYmVsKC10ZXh0ID0+ICJjb25m
aWd1cmUgJ2Zyb20nIG9mIFNVVDoiKS0+cGFj
aygtYW5jaG9yID0+ICd3Jyk7DQpteSAkZnJvbSA9
ICRtdy0+U2NhbGUoLWZyb20gPT4gMCwgLXRv
ID0+IDEwLCAtcmVzb2x1dGlvbiA9PiAxLCAtdGlj
a2ludGVydmFsID0+IDEsDQogICA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C1vcmllbnQgPT4gJ2hvcml6b250YWwnLCAt
d2lkdGggPT4gOCwgLWxlbmd0aCA9PiAzMDAs
IC1zbGlkZXJsZW5ndGggPT4gMTYsDQogICAgICAg
ICAgICAgICAgICAgICAgLXZhcmlhYmxlID0+
IFwkdGlja1ZhbCwNCiAgICAgICAgICAgICAgICAg
ICAgICAtY29tbWFuZCA9PiBzdWJ7JHNjYWxl
LT5jb25maWd1cmUoLXJlc29sdXRpb24gPT4gJHRp
Y2tWYWwpfSktPnBhY2soKTsNCg0KJG13LT5C
dXR0b24oLXRleHQgPT4gJ0V4aXQnLCAtY29tbWFu
ZCA9PiBzdWIgeyBleGl0IH0pLT5wYWNrKCk7
DQoNCk1haW5Mb29wOw==

-- 0__=4EBBE51DDFAD12BD8f9e8a93df938690918c
4EBBE51DDFAD12BD
Content-type: application/octet-stream;
name="testScale.tcl"
Content-Disposition: attachment; filename="testScale.tcl"
Content-transfer-encoding: base64

IyEvdXNyL2Jpbi93aXNoCgpsYWJlbCAuc3V0dHh0
IC10ZXh0ICJTY2FsZSBVbmRlciBUZXN0IChT
VVQpOiIKcGFjayAuc3V0dHh0IC1hbmNob3IgdwoK
c2NhbGUgLnN1dCAtZnJvbSAwIC10byAyMCAt
cmVzb2x1dGlvbiAxIC10aWNraW50ZXJ2YWwgMSBc
CiAgICAgICAgICAgLW9yaWVudCBob3Jpem9u
dGFsIC13aWR0aCA4IC1sZW5ndGggMzAwIC1zbGlk
ZXJsZW5ndGggMTYgXAogICAgICAgICAgIC12
YXJpYWJsZSBzY2FsZVZhbCAtY29tbWFuZCByZXAK
cGFjayAuc3V0CgpzZXQgZnJvbVZhbCAwCmxh
YmVsIC5mcm9tdHh0IC10ZXh0ICJjb25maWd1cmUg
J2Zyb20nIG9mIFNVVDoiCnBhY2sgLmZyb210
eHQgLWFuY2hvciB3CnNjYWxlIC5mcm9tIC1mcm9t
IDAgLXRvICAxMCAtcmVzb2x1dGlvbiAgMSAt
dGlja2ludGVydmFsICAxIF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bCIKfQoKcHJvYyBjaGFuZ2VGcm9t
IHtmfSB7CiAuc3V0IGNvbmZpZyAtZnJvbSAk
Zgp9CnByb2MgY2hhbmdlUmVzIHtyfSB7CiAuc3V0
IGNvbmZpZyAtcmVzb2x1dGlvbiAkcgp9CnBy
b2MgY2hhbmdlVGljayB7dH0gewogLnN1dCBjb25m
aWcgLXRpY2tpbnRlcnZhbCAkdAp9Cg==

-- 0__=4EBBE51DDFAD12BD8f9e8a93df938690918c
4EBBE51DDFAD12BD--

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu

konovalo

2005-01-19, 8:59 pm


>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
>
>


I noticed your perlTk code different from Tcl code, for example

$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();

you promise configuring tickinterval but instead configure resolution;
-to values are also not consistent.

However, if you have both Tcl/Tk and perlTk of same code, I strongly
advice looking into Tcl::Tk perl module from CPAN.
Tcl::Tk able to run pure-Tcl code at one side, and , from another side,
your perlTk version will work from within Tcl::Tk when you will replace
"use Tk;" line with "use Tcl::Tk qw(:perlTk);"
So it will be easier for you to compare behaviours.

Tcl::Tk translates your perlTk code into Tcl/Tk widget directives, and
final GUI processor will be Tcl/Tk
I often uses both approaches from within same script, and find this
quite convenient.
Note, though, that currently CVS version of Tcl::Tk module contains more
complete documentation, compared to current CPAN version.

Best regards,
Vadim..




-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu

gerhard.petrowitsch@philips.com

2005-01-20, 8:57 am

Hi Vadim,

yes, sorry, that one slipped through - another copy-and-past error :-((
So at least configuring the tickinterval doesn't change the resolution.

My intention was not to compare Tcl / Perl Tk behaviour but
to point out that the Scale widget has problems when
configured to resolutions other then 1 when the 'from' value is
not on the same resolution grid with the origin at 0.

So it's not possible to set -resolution => 3, -from => 1 for instance.
-from can only be 0, 3, 6... in this case!

I included the Tcl code because as far as I know the Perl/Tk
code is derived from the Tcl/Tk code.

Regards,
Gerhard




|---------+---------------------------->
| | |
| | |
| | |
| | |
| | |
| | konovalo |
| | <konovalo@mail.wplus.net|
| | > |
| | |
| | Sent by: |
| | owner-ptk@lists.Stanford|
| | .EDU |
| | |
| | 2005-01-19 06:20 PM |
| | |
|---------+---------------------------->
>---------------------------------------------------------------------------------------------------------------------------|

| |
| To: Gerhard Petrowitsch/STN/SC/PHILIPS@PHILIPS |
| cc: ptk@lists.Stanford.EDU |
| Subject: Re: odd behaviour of Scale widget |
| |
| Classification: |
| |
| |
>---------------------------------------------------------------------------------------------------------------------------|






>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
>
>


I noticed your perlTk code different from Tcl code, for example

$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();

you promise configuring tickinterval but instead configure resolution;
-to values are also not consistent.

However, if you have both Tcl/Tk and perlTk of same code, I strongly
advice looking into Tcl::Tk perl module from CPAN.
Tcl::Tk able to run pure-Tcl code at one side, and , from another side,
your perlTk version will work from within Tcl::Tk when you will replace
"use Tk;" line with "use Tcl::Tk qw(:perlTk);"
So it will be easier for you to compare behaviours.

Tcl::Tk translates your perlTk code into Tcl/Tk widget directives, and
final GUI processor will be Tcl/Tk
I often uses both approaches from within same script, and find this
quite convenient.
Note, though, that currently CVS version of Tcl::Tk module contains more
complete documentation, compared to current CPAN version.

Best regards,
Vadim..




-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu



-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu

gerhard.petrowitsch@philips.com

2005-01-21, 8:58 am

Wolfgang,

thanks for your reply. I understand your points, but...

what sense does it make to put -from and -to on the resolution
grid and at the same time fix the origin of that grid to 0?

I would rather expect, that if there's a resolution other than 1,
and the user configures the -from value, it should be possible
to have it on ANY value and only the -to value is adapted
by the widget code.
Likewise for the -from value, if the -to value is configured by
the user.

I must admit that I don't have a straightforward solution
to what should happen, if the -resolution is configured.
I would tend to leave the -from value as it is (as it is the
origin) and adapt the -to value. Same is true for widget
creation or when the configure call contains all switches
(-from, -to and -resolution).

I'm using the Scale widget wrapped into an object to
present it to the user of my application. And I took the
same approach as you mentioned to avoid the values
getting all bigger all the time: Save the value, that was
last set by the user.

If all agree:
Will there anyone take action in this issue (I mean change
the tkScale.c code and talk the Tcl/Tk people into it, too)?

Thanks & regards,
Gerhard



|---------+---------------------------->
| | |
| | |
| | |
| | |
| | |
| | LAUN Wolfgang |
| | <wolfgang.laun@alcatel.a|
| | t> |
| | |
| | 2005-01-21 06:50 AM |
| | |
|---------+---------------------------->
>---------------------------------------------------------------------------------------------------------------------------|

| |
| To: Gerhard Petrowitsch/STN/SC/PHILIPS@PHILIPS |
| cc: "'ptk@lists.Stanford.EDU'" <ptk@lists.Stanford.EDU> |
| "'nick@ing-simmons.net'" <nick@ing-simmons.net> |
| Subject: Re: odd behaviour of Scale widget |
| |
| Classification: |
| |
| |
>---------------------------------------------------------------------------------------------------------------------------|





Gerhard Petrowitsch wrote on Wed, 19 Jan 2005 14:43:58 +0100:
> I noticed, that the Scale widget is buggy or at least odd behaving
> during this reconfigurations sometimes.
>
> 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 just want to ask, who could debug this


Well, the code in tkScale.c is plain enough: the -from, -to and
-tickinterval values (and the current scale value too, of course)
are rounded to the nearest integer multiple of the -resolution value.
This is documentated. What is missing from the doc and causes some
strange behaviour is the fact that the original values as defined
by the user are overwritten by the rounded value.

For instance, by increasing the -resolution from 1 by 1, for some
other value that's 1 at the outset, we see an ever-increasing
series for that other value, too:
r=1, 1->1; r=2, 1->2; r=3, 2->3; etc.

This would be eaasy to fix by saving the original values. But the
code being part of Tcl/Tk, such a change should be originated elsewhere.

Kind regards
Wolfgang






-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com