Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Dynamic menus in Perl/Tk giving error

by bibliophile (Parson)
on Dec 23, 2005 at 21:02 UTC ( #518829=perlquestion: print w/ replies, xml ) Need Help??
bibliophile has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed monks,

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:

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.
I've been able to reproduce this with a minimalist example:
#!/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;
Doing a SuperSearch for keywords "application requested Runtime terminate unusual" didn't turn up anything.

I'm sure I am not understanding some fundamental Tk concept here... can anyone point me in the right direction?

-- -David

Comment on Dynamic menus in Perl/Tk giving error
Select or Download Code
Re: Dynamic menus in Perl/Tk giving error
by BrowserUk (Pope) on Dec 23, 2005 at 21:10 UTC

    Which versions of Perl, Tk, and OS are you running?

    Your snippet runs and exits clean on my system. (XP/AS815/804.027).


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I'm running ActiveState Perl 5.8.2 on WinXP SP2:

      C:\wrk\hmm>perl -v This is perl, v5.8.2 built for MSWin32-x86-multi-thread (with 25 registered patches, see perl -V for more detail) Copyright 1987-2003, Larry Wall Binary build 808 provided by ActiveState Corp. http://www.ActiveState. +com ActiveState is a division of Sophos. Built Dec 9 2003 10:19:40
      Oop: and...
      C:\wrk\Tk-MARC_Editor-0.5>perl -e "use Tk; print $Tk::version . $/;" 8.0
      -- David

        That your snippet runs clean here would tend to indicate that there is nothing wrong with your code; which leaves you in the position of deciding what you should upgrade to fix the problem.

        As AS Perl comes with Tk, if upgrading Perl is an option for you, that would probably be the path of least resistance. I've successfully installed the last half dozen AS binary distributions over the top of their predecessors, thus avoiding having to re-build/reinstall all the modules I've added to my distribution, and have yet to find a binary incompatibility. However, I do not run any "production code", or anything vital to me.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://518829]
Approved by BrowserUk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2014-12-21 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls