use Tk; use Tk::Trace; use Tk::Text; my $system = {}; @{$system->{gui}->[0]->{cut_ctl_1}} = ("start", "normal"); @{$system->{gui}->[0]->{cut_ctl_2}} = ("remove", "normal"); $system->{gui}->[0]->{progress}->[0] = "Not running"; my $mainwindow = MainWindow->new(); my $but_ctl_1 = $mainwindow->Button(-textvariable=>\$system->{gui}->[0]->{but_ctl_1}->[0], -state=>$system->{gui}->[0]->{but_ctl_1}->[1])->grid(-row=>0, -column=>0, -sticky=>"nsew"); my $but_ctl_2 = $mainwindow->Button(%{-textvariable=>\$system->{gui}->[0]->{but_ctl_2}->[0], -state=>$system->{gui}->[0]->{but_ctl_2}->[1])->grid(-row=>1, -column=>0, -sticky=>"nsew"); my $progress = $mainwindow->Scrolled('Text', -scrollbars=>'osoe', -height=>5, -width=>30)->grid(-row=>2, -column=>0, -sticky=>"nsew"); $progress->Subwidget('scrolled')->insert( 'end', "$system->{gui}->[0]->{progress}->[0]" ); #traces: $frame->traceVariable( \$system->{gui}->[0]->{progress}->[0], 'w', [ \&text_update, $progress->Subwidget('scrolled')] ); $frame->traceVariable( \$system->{gui}->[0]->{but_ctl_1}->[1], 'w', [ \&state_update, $but_ctl_1] ); $frame->traceVariable( \$system->{gui}->[0]->{but_ctl_2}->[1], 'w', [ \&state_update, $but_ctl_2] ); $mainwindow->after(5000, sub{ $system->{gui}->[0]->{progress}->[0] = "RUNNING"; $system->{gui}->[0]->{but_ctl_1}->[1] = "disabled"; }); MainLoop(); sub text_update { my ($index, $value, $op, $t) = @_; return unless $value; $t->delete("1.0", "end"); $t->insert( 'end', "$value" ); return $value; } sub state_update { my ($index, $value, $op, $b) = @_; return unless $value; $b->configure(-state=>$value); return $value; }