bibliophile has asked for the wisdom of the Perl Monks concerning the following question:
Esteemed monks,
Doing a SuperSearch for keywords "application requested Runtime terminate unusual" didn't turn up anything.
I'm trying to have a Perl/Tk application create menus on the fly, depending on current state. This works... mostly. When I exit the application, I get an error message along the following lines:
I've been able to reproduce this with a minimalist example:18e6748 is not a hash at C:/Perl/site/lib/Tk.pm line 340. This application has requested the Runtime to terminate it in an unusu +al way. Please contact the application's support team for more information.
#!/usr/bin/perl use Tk; my $mw = MainWindow->new; my $txt = $mw->Text()->pack(-side => 'top'); my $number = 1; my $letter = 'a'; my $popup_menu = ""; my $new_menu = $mw->Menu(); $new_menu->add('command', -label => "Click me to show the pop-up menu.", -command => sub { $popup_menu = $mw->Menu(); $popup_menu->add('command', -label => "Number: $number", -command => sub { print STDERR "Number: $number\n"; $number++; } ); $popup_menu->add('command', -label => "Letter: $letter", -command => sub { print STDERR "Letter: $letter\n"; $letter++; } ); $popup_menu->Popup(qw/-popover cursor/); } ); $txt->menu( $new_menu ); MainLoop;
I'm sure I am not understanding some fundamental Tk concept here... can anyone point me in the right direction?
--
-David
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Dynamic menus in Perl/Tk giving error
by BrowserUk (Patriarch) on Dec 23, 2005 at 21:10 UTC | |
by bibliophile (Prior) on Dec 23, 2005 at 21:20 UTC | |
by BrowserUk (Patriarch) on Dec 23, 2005 at 21:32 UTC | |
by bibliophile (Prior) on Dec 23, 2005 at 21:45 UTC |
Back to
Seekers of Perl Wisdom