Thanks for telling me about trace. I will give that a try and update with results and working example.

Works, here is what I did for the next person who needs to know.

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', -hei +ght=>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; }

In reply to Re: Tk Button state tied to variable by glenn
in thread Tk Button state tied to variable by glenn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.