in reply to Why does widget->destroy give the error Tk::Error widget was deleted before its visibility changed?
Where did you get this sample?
Tk::Error: window ".toplevel.frame1.hlist.menu" was deleted before its visibility changed ... You don't recieve the error if you only push the Exit button.
That is because no Menu object is created, and then destroyed before it could be displayed.
sub knock_on_door always creates a new menu in $popup_menu, and that variable always goes out of scope and is supposed to be destroyed, but Tk does you a favor and keeps it around because its knows you're not Coping with Scoping
Make sense?
If you make it a global and the only one, then you won't get that message
#~ my $pop_menu = $frame->Menu( -menuitems => our $pop_menu ; $pop_menu ||= $frame->Menu( -menuitems =>
But that isn't good practice, see tips at Re^3: Perl Tk Multiple Notebook Editing and Save (life cycle of variables) and the links it links
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why does widget->destroy give the error Tk::Error widget was deleted before its visibility changed?
by thomas.bystrom (Novice) on Apr 17, 2015 at 12:22 UTC | |
by boleary (Scribe) on Jun 11, 2017 at 21:22 UTC | |
by Anonymous Monk on Jun 12, 2017 at 04:54 UTC | |
by boleary (Scribe) on Jun 12, 2017 at 11:30 UTC | |
by Anonymous Monk on Jun 12, 2017 at 22:21 UTC |