Scale widget executes it's command when mapped

[email protected]
Newsgroups gmane.comp.lang.perl.tk
Message-ID <OF1C1A7152.DD294EC0-ONC1256F90.0027EBF1-C1256F90.0028C29F@philips.com>
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).
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'.

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.

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 [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.