in reply to Perl Tk - Change button state based on event
Here is a way, polling
About every second, it checks to see if both Entry widgets have a text length greater than zero, and disables/enables the button#!/usr/bin/perl -- use strict; use warnings; use Tk; my $mw = tkinit; my $bu = $mw -> Button(-text => "OK", -state=>'disabled')->pack(); my @te ; push @te, $mw->Entry()->pack; push @te, $mw->Entry()->pack; $mw->repeat( 900, sub { my $state = $bu->cget('-state') ; my $both = @te == grep { $_->index('end') } @te; if( $state ne 'normal' and $both ){ $bu->configure( -state => 'normal' ); } elsif( not $both ){ $bu->configure( -state => 'disabled' ); } }, ); MainLoop;
|
|---|