in reply to perl tk button on windows 8 touchpad does not animate if touched as expected

the finger touch make the -command sub work as expected but the button is freezed. Is there a way to make a widget button act as a normal button

I have no Tablet, but just shooting the breeze, how about manually changing the button's state in the -command callback?

For a simple example:

#!/usr/bin/perl use strict; use Tk; my $mw = MainWindow->new; my $but; # declare before so you can use it in the callback $but = $mw->Button(-text => "Hello World", ## This callback works (text is changed) under Win95, Win98 (5.6.1) # # -command => [sub { my $b = $_[0], #notice comma # $b->configure(-text => "Hello Stranger"); # }, $b]); #This callback works under Win95, Win98 (5.6.1) and Linux (5.6.0) -command=>[\&change, $but]); $but->pack; MainLoop; sub change { my $but = $_[0], #notice comma $but->configure(-text=>"Hello Stranger", -bg => 'pink'); }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
  • Comment on Re: perl tk button on windows 8 touchpad is doesn't not animate if touched
  • Download Code

Replies are listed 'Best First'.
Re^2: perl tk button on windows 8 touchpad is doesn't not animate if touched
by abonvici (Initiate) on May 07, 2014 at 19:29 UTC

    Thank a lot Zentara . i'll try your suggestion tomorrow at work , where i have the touchpad, and a i'll let you know. Only one doubt. How to force the button update to show the state change? .Could be sufficient call tk::button->update?

      HI all , I workaround this problem doing a change of the background of the button at the begining and the ending of the -command action. As the -command action is relatively long this work in an acceptable way. From a logic point of view:

      -command => sub { my $caller_ = $Tk::widget; $caller_->configure(-bg ='red'); $caller_->update; ........................ .....long operation on db $caller_->configure(-bg ='grey'); $caller_->update; }

      This work quite well for my needs . Thank a lot

        .....long operation on db

        Hi, I would just mention that your Tk interface may become unresponsive during that long operation, since it will block the Tk event-loop. You may want to sprinkle some $mw->update; statements in your long db operation, if possible, to keep the eventloop active. For instance, what if you wanted a Cancel button to cancel the long db operation midstream? The Cancel button will not respond.

        There are ways around this, like using threads or forks to do the long db operation and set a threads shared variable when done. But that is getting way beyond what you probably want to do.

        See PerlTk on a thread... for an introduction.

        BTW, did $button->activate() in the -command callback give any animation?


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh