logo       

Re: Scale widget executes it's command when mapped: msg#00056

Subject: Re: Scale widget executes it's command when mapped

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



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    politics.lenini...    audio.emagic.ex...    tex.texinfo.gen...    handhelds.linux...    ietf.sipping/20...    lang.erlang.gen...    cygwin.talk/200...    yellowdog.gener...    mozilla.devel.l...    xfree86.newbie/...    openbsd.ports/2...    db.oracle.devel...    kde.kalyxo.deve...    user-groups.lin...    bbc.cvs/2003-04...    gnu.libtool.bug...    redhat.k12osn/2...    emulators.wine....    freebsd.devel.d...    search.xapian.g...    java.izpack.use...    network.mrtg.us...    windows.total-c...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe