In a previous message I asked about exiting from 'MainLoop', and got a couple of answers. One included exactly what I needed for one instance (Message Box). Now I'm trying to pop up a box (Yes, this is W-XP [yuck!]) and have a couple of selections to pick from. I thought I would use a dialog box, and I'm trying this simple code:
#!/bin/perl -w # Try to get a simple dialog box to work. use Tk; # Bring in the Tk stuff. use Tk::DialogBox; my $mw = MainWindow->new; # Get rid of main window, but keep some of it around. $mw->withdraw(); print "Main window created, withdrawn\n"; my $dialog = $mw->DialogBox (-title => "Please pick one of the three", -buttons => ["One", "Two", "Three"]); my $item = $dialog->Show(); # ??? print "Returned from the show, got $item\n"; # Done
The problem is that the above example when run on WXP hangs at the ->Show() statement. From what I can tell, the execution focus is somewhere else (it goes away from my command window) and it may be displaying something "invisable". Since it isn't displayed, I can't do anything, and it hangs. To exit, I type ^C and the interrupt kills the script. Can this be made to work? I was very able to get the messageBox to function WITHOUT going into 'MainLoop', can I do something similar here???

Your wisdom would be quite helpful. Past incantations of wisdom have been MOST helpful!! Thanks!!

Update:

It seems that the dialog box is tightly linked to the parent window. They can't (with the code above) be seperated. Even if I try to 'deiconify' the dialog box, until the main window becomes 'normal' it won't happen! Somehow 'messageBox' is able to disconnect these, but THAT is buried pretty deeply in the Tk library (I tried to look for how without luck). Still looking for "secret sauce".


In reply to Perl/Tk: Dialog boxes for idiots (me) by herby1620

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.