Hi, when you post code, you can enclose the words code and /code in angle<> brackets. This helps with the formatting!

Update: Oh, I see,usleep(2500000); this is a problem!, you don't want to sleep! If you do that, the stuff that runs the GUI is not gonna be running. Once you start the GUI, it waits for some event to happen.
original post continues, may still be of value to you...

Here is a snippet from one of my programs. The text variable is where the stuff goes that is typed in (there is a search command that the user types in here). Then I bind the RETURN key to an anon sub that just calls another routine. I haven't used this waitVariable thing and I'm not sure what it would different than this. Our functional requirement sounds similar so...here's some code..

$f_dialog->Label (-text => 'Search Query')->pack(-side=>'left'); my $e_search =$f_dialog->Entry (-textvariable => \$tv_search_command,) +->pack(-side=>'left'); $e_search->bind("<Return>", sub {enter_pressed();} ); ...... sub enter_pressed() { #first few lines of this sub... $text->delete("1.0", 'end'); #Update 000ops this is for another wind +ow #not needed for entry window #I think text visible to user entry gets #cleared by the time we are here. #I do think making a copy of entered text for #further processing is good idea though... my $search_command = $tv_search_command; ....blah }
I think you can just give the address of "enter_pressed()" rather they way this was done. This anon sub may have done more than just call one routine in the past, its been a few years since I've looked at this code. Of course you may not need a separate sub and can do it all in the anon sub. Adapt as you need.

If you want a button instead of using Return, then you don't need the bind. Just associate a routine with a click button.


In reply to Re: How to use waitVariable by Marshall
in thread How to use waitVariable by BGriff

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.