On Jan 21, 2005, at 2:24 AM, gerhard.petrowitsch@xxxxxxxxxxx wrote:
Hi all,
talking about the Scale widget, I remembered another issue.
Unlike other widgets (like Button, Checkbutton, ...), the Scale
widget executes it's -command code, when it's mapped (or
close to that time).
Yes, that's known .. IIRC a few other widgets do that as well. I think
I (at one time) had a reasonable work-around, but nothing comes to
mind.
See this little example:
use Tk;
my $mw = MainWindow->new();
$mw->Scale(-from => 0, -to => 10, -length => 300, -width => 10,
-command => sub { print "*" })->pack();
$mw->Button(-text => "Test", -command => sub { print "+" })->pack();
MainLoop;
When you start it, it immediately prints a * to the shell, but
no +. So the Button behaves as expected, the Scale
act 'prematurely'.
Here's a kluge:
#!/usr/local/bin/perl -w
use Tk;
my $mw = MainWindow->new();
my $s = $mw->Scale(-from => 0, -to => 10, -length => 300, -width =>
10)->pack();
$mw->update; $s->configure( -command => sub { print "*" } );
$mw->Button(-text => "Test", -command => sub { print "+" })->pack();
MainLoop;
That is does so is annoying and doesn't make sense to me.
I always have to build this 'return unless ($first++)' type of
code into the command code of the Scale.
With luck an expected snow storm will trap me in front of my computer
this weekend and I'll address this and all your previous mails ;)
Regards,
Gerhard
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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@xxxxxxxxxxxxxxxxxx
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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@xxxxxxxxxxxxxxxxxx
|