in reply to Re: Why does widget->destroy give the error Tk::Error widget was deleted before its visibility changed?
in thread Why does widget->destroy give the error Tk::Error widget was deleted before its visibility changed?

Thanks!

Your response pushed me forward.
I did'nt solve the problem with making the pop_menu global.
My solution is to withdraw the widget, because I want to reuse it later in my script (10 000 rows in 8 pm files).

Thanks again for your Quick response.

  • Comment on Re^2: Why does widget->destroy give the error Tk::Error widget was deleted before its visibility changed?

Replies are listed 'Best First'.
Re^3: Why does widget->destroy give the error Tk::Error widget was deleted before its visibility changed?
by boleary (Scribe) on Jun 11, 2017 at 21:22 UTC

    I am facing the same problem in several places in my application where I am using a menu bound to an hlist.

    I do not understand the proposed solution and how scoping plays a part

    In my application I am assigning the menu object to a hash element so that I can refer to it and try to destroy it when the window is going to close. like this:

    $winInfoRef->{MENU}= $winInfoRef->{HLIST}->Menu(-tearoff=>1,

    I have recreated the problem with the originally posted example code, I changed the lines to make $pop_menu a global as suggested (and relisted below)

    #~ my $pop_menu = $frame->Menu( -menuitems => our $pop_menu ; $pop_menu ||= $frame->Menu( -menuitems =>

    but I still get the same error:

    Tk::Error: window ".toplevel.frame.hlist.menu" was deleted before its +visibility changed at C:/Perl/site/lib/Tk/Widget.pm line 1000. Tk callback for tkwait <Button-1> (command bound to event)

    Thomas said he withdrew his menu, but I tried that too with no success(maybe I don't know how) Can anyone share more insight into this error?

      to Tk-804.033, then you don't have to learn anything
        perl -v v5.22.2 (32 bit)
        perl -MTk -e "print $Tk::VERSION" shows 804.033

        Were you implying that this version should have fixed a problem with destroying the popup menu?

        Thanks!