in reply to Execute Tk::Button every X interval while button is pressed (and not released)

I figured it out, without having to bind a callback to the button (using the "-command" option)

use warnings; use strict; use Tk; my $num = 0; my $mw = tkinit(); my $button = $mw->Button( -text => $num, -repeatdelay => 25, -repeatinterval => 25, -command => sub{ buttonPressed(); } )->pack(); $mw->MainLoop(); sub buttonPressed{ #this subroutine will be executed if the button is clicked once, #or repeatedly executed if the button is held down. print "."; $button->configure(-text => $num++); }
  • Comment on Re: Execute Tk::Button every X interval while button is pressed (and not released)
  • Download Code

Replies are listed 'Best First'.
Re^2: Execute Tk::Button every X interval while button is pressed (and not released)
by Anonymous Monk on Feb 13, 2012 at 21:04 UTC
    use Tk; sub w{ warn @_ } tkinit->Button( qw/ -repeatdelay 25 -repeatinterval 25 -command /, \&w, )->pack; MainLoop;