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

I have a <Tab> binding for a entry widget, where I destroy the widgets parent after processing. I get an error because after running my subroutine Tkx tries to find the field for the next focus for the parent widget that does not exist anymore:

bad window pathname ".t.e"

I would like to use the break command (as mentioned in the documentation of bind) to prevent Tkx from executing further bindings. However, all syntaxes I could think of give an error. Obviously I can't think of the right syntax OR the break command does not funktion.

This is the stripped code:

use strict; use warnings; use Tkx; my $mw = Tkx::widget -> new ('.'); $mw -> g_wm_iconify; my $Fkrs = $mw -> new_toplevel; my $fac = ''; my $Ffac = $Fkrs -> new_entry (-textvariable => \$fac, -width => 8); $Ffac -> g_grid (-row => 0, -column => 0, -sticky => 'ew'); $Ffac -> g_bind ('<Tab>', [\&fac, \$fac, \$Ffac, \$Fkrs]); Tkx::update (); while (Tkx::i::call('winfo', 'exists', $Fkrs)) {Tkx::i::DoOneEvent(0)} +; Tkx::update (); die "Normal end"; sub fac { my ($p_fac, $p_Ffac, $p_Fkrs) = @_; if ($$p_fac =~ /^(?=.+)\d*(\.\d+)?$/) { # I would like to use the break here!!; $$p_Fkrs -> g_destroy; } else { $$p_fac = ''; } }

Replies are listed 'Best First'.
Re: Use of break in Tkx
by previous (Sexton) on Oct 03, 2015 at 10:17 UTC
    ok I did
    sub cb_entry { my $win=$_[0]; $mw->g_wm_title("this is $win m8"); Tkx::break(); }
    and the error message pops up. I can see that the second entry never gets reached but am not sure if this is because of the error or whether the error is harmless. Back to activestate I think. I came here from there but they just said read the TK docs.
        Yes I'm slowly seeing that... I just modified the callback to subdue the error and break in the forms I've tried isn't "doing" it. Thanks for the advice
        sub custom_error_handler {} #just supresses error sub cb_entry { my $win=$_[0]; eval { $mw->g_wm_title("this is $win m8"); #this works ok #NONE OF THESE DO ANYTHING Tkx::break(); $win->break; Tkx::break(".e"); }; custom_error_handler($@) if $@; }
Re: Use of break in Tkx
by Anonymous Monk on Mar 29, 2013 at 13:31 UTC
      Nope, doesn't.
      For information: I am using ActiveState Perl v. 5.14.2, Tkx (and Tcl) are standard included, Tk isn't.
      OS is Windows 7 64-bit.

        Nope, doesn't.

        Sure it does, if you insert it at "break here" it will break -- it still pops up an error dialog (not very useful) but it calls break and breaks :) you should report bug to Tkx author

        ... Tk isn't.

        And then you install Tk