I'm trying to call configure for a widget that is in a different frame to the one the current callback is running from. It doesn't work, I'm getting Tk::Error output. System is Debian Bullseye. code is:

#!/usr/bin/perl use strict; use Tk; use Tk::TFrame; my $con_but_txt = "Connect"; my $online = 0; my $rd_b2; # Set the software version and display it! my $statusmsg = 'Version 0.1'; #------------ my $mw = MainWindow->new; #------------ my $seg2_f = $mw->TFrame(-label => 'Segment 2', -relief => 'groove', -borderwidth => 2); $rd_b2 = $seg2_f->Button(-text => "Read", -state => 'disabled', -comma +nd => [\&read_seg, 2]); $rd_b2->grid(-row => 3, -column => 1, -sticky => "e", -padx => 4); my $ts_e2 = $seg2_f->Text(-wrap => 'word', -width => 50, -height => +6)->grid( -padx => 4, -p +ady => 4, -row => 0, -co +lumn => 3, -sticky => "ns +ew", -rowspan => 4); $seg2_f->grid(-row => 1, -column => 0, -sticky => "nsew",-padx => 2); #------------- my $base_f = $mw->Frame( -relief => 'groove', -borderwidth => 2); my $status = $base_f->Label(-textvariable => \$statusmsg, -borderwidth + => 2, -width => 20, -relief => 'groove')->grid(-row => 1, +-column => 0, -sticky => "w",-padx => 2,-pady => 3); my $conn_b = $base_f->Button(-textvariable => \$con_but_txt, -command +=> \&connect)->grid(-row => 1, -column => 3, -sticky +=> "e"); $base_f->Button(-text => "Exit", -command => sub {exit})->grid(-row => + 1, -column => 4, -sticky => "e" +); $base_f->grid(-row => 2, -column => 0, -sticky => "w",-padx => 2); #------------- #----------------------------------------- sub read_seg { my $cnt; my $inpstr; my ($segnum) = @_; $statusmsg = sprintf("Reading Segment %d", $segnum); $mw->update(); $mw->after(500); $statusmsg = "Online"; $mw->update(); } sub connect { my $cnt; my $inpstr; # Connect / Disconnect # if ($online == 0) { $online = 1; $con_but_txt = "Disconect"; $statusmsg = 'Online'; } else { $online = 0; $con_but_txt = "Connect"; $statusmsg = 'Offline'; } update_buttons(); } # Enable/Disable various buttons # sub update_buttons { if ($online == 0) { # We are Offline # $rd_b2->cofigure(-state => 'disabled'); $mw->$seg2_f->$rd_b2->cofigure(-state => 'disabled'); } else { # We are Online # $rd_b2->cofigure(-state => 'normal'); $mw->$seg2_f->$rd_b2->cofigure(-state => 'normal'); } }

As you can see from update_buttons I've tried just the widget handle and also a chain down from $mw. Both give output like:

Tk::Error: Can't locate auto/Tk/TFrame=HASH(0x55a20d8dde70).al in @INC + (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32. +1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 / +usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-l +inux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at +./test.pl line 91. Carp::croak at /usr/lib/x86_64-linux-gnu/perl-base/Carp.pm line 289 AutoLoader::autoload_sub at /usr/lib/x86_64-linux-gnu/perl-base/AutoL +oader.pm line 54 AutoLoader::AUTOLOAD at /usr/lib/x86_64-linux-gnu/perl-base/AutoLoade +r.pm line 23 main::update_buttons at ./test.pl line 91 main::connect at ./test.pl line 80 Tk callback for .frame.button Tk::__ANON__ at /usr/lib/x86_64-linux-gnu/perl5/5.32/Tk.pm line 251 Tk::Button::butUp at /usr/lib/x86_64-linux-gnu/perl5/5.32/Tk/Button.p +m line 175 <ButtonRelease-1> (command bound to event)

I'm obviously doing something stupid, but it's been 10 years since I wrote any serious Perl and I can't see my mistake. Help please


In reply to PerlTk using -configure across frames by colintu

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.