merrymonk has asked for the wisdom of the Perl Monks concerning the following question:

I got this error message:
[once] w <Tk::Frame=HASH(0x295d6a76518)> XS_Tk__Callback_Call error:bad anchor "sec": must be n, ne, e, se, s, +sw, w, nw, or center at ……../site/lib/Tk/Widget.pm line 1218. …../site/lib/Tk/After.pm line 93.
and I could not find the problem widget.

I had edited the After.pm to be as below

sub once { my $obj = shift; my $w = $obj->[0]; my $id = $obj->[1]; print "[once] w <$w> \n"; delete $w->{_After_}{$id}; local $Tk::widget = $w; $obj->[4]->Call; }
Line 93 is the last line.
I guess it would help if I could get the name of the widget from the data in the HASH.
However, I do not know how to do this – can some monk please help me?

Replies are listed 'Best First'.
Re: Decoding a frame HASH entry
by choroba (Cardinal) on Feb 03, 2020 at 22:17 UTC
    You seem to be setting the -anchor of a widget to "sec" which is not a valid value.

    Instead of editing Tk/After.pm, you can redeclare the method from your code:

    use Data::Dumper; my $orig = *Tk::After::once{CODE}; local *Tk::After::once = sub { warn Dumper \@_; $orig->(@_) };

    You should see something like

    ... $VAR1 = [ bless( [ bless( { '_After_' => { 'after#2' => $VAR1->[0] }, '_TkValue_' => '.frame.message', '_Destroy_' => [ bless( [ sub { "DUMMY" }, $VAR1->[0][0] ], 'Tk::Callback' +) ] }, 'Tk::Message' ), 'after#2', 1000, 'once', bless( [ sub { "DUMMY" } ], 'Tk::Callback' ) ], 'Tk::After' ) ];

    In this case, the widget was a Tk::Message. I fear yours will be a Frame, as that's the type of $w, but maybe the additional information will help you identify it further.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: Decoding a frame HASH entry
by Anonymous Monk on Feb 04, 2020 at 12:31 UTC
       use Tk; my $mw = tkinit; $mw->Button->pack for 1..3; $mw->WidgetDump; MainLoop;

      Name: button1 PathName: .button1 [Flash widget]

      $ww->Name = [ 'button1' ]; $Error = ''; @res = <button1>

      $ww->PathName = [ '.button1' ]; $Error = ''; @res = <.button1>