#!/usr/bin/perl use warnings; use strict; use Tk; use Tie::Watch; my $mw = MainWindow->new; $mw->fontCreate('big', -weight=>'bold', -size=> 18 ); my $foo='neutrino'; my $watch = Tie::Watch->new(-variable => \$foo, -store => \&store_callback); my $entry = $mw->Entry(-textvariable => \$foo, -bg => 'white', -font => 'big')->pack; $entry->icursor('end'); $entry->focus; my $testbutton; $testbutton = $mw->Button(-text => 'Foo Watcher', -state => 'disabled', -command => sub{ print "$foo\n"; $testbutton->configure(-state => 'disabled', -bg=>'white', -activebackground => 'white', ); }, -bg => 'white', -font => 'big', )->pack; my $quit = $mw->Button(-text => 'Quit', -command => sub { print "Final value=$foo.\n"; exit; })->pack; # a simple MainLoop; sub store_callback { print "In store_callback, self=$_[0], new_value=$_[1].\n"; $testbutton->configure( -state => 'normal', -bg => 'yellow', -activebackground => 'yellow', ); $_[0]->Store($_[1]); }