Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks, I have a Wx app that requires user input at some point during the process. Is there a more elegant solution for having the app wait when it encounters this point instead of using a while loop? It isn't using any dialog boxes. I currently use a while loop like so to wait until the user clicks my button to continue:
# User is prompted to enter info ... while (!$proceed) { # App waits until button is clicked } # User enters info and clicks button to proceed (e.g. $proceed = 1)
This is also a threaded process if that helps. Any suggestions would be appreciated.

Replies are listed 'Best First'.
Re: GUI input wait?
by moritz (Cardinal) on Jul 07, 2008 at 14:55 UTC
    There is a more elegant way. I think that Wx apps are event based, so you can just do everything after your while loop into the appropriate event handler.
Re: GUI input wait?
by zentara (Cardinal) on Jul 07, 2008 at 17:21 UTC
    I don't use Wx, but from my experience with Tk and Gtk2, a while loop will prevent your Wx event loop from running. This may not be a problem if there is nothing going on in the background, but if there are other timers and filehandle watchers running, they will be stopped during your while loop. The best bet is to use a dialog, or entry to get the info. You could also setup a io (filehandle ) watcher on STDIN, and that would collect input. Dialogs or entrys will work cleaner.

    I'm not really a human, but I play one on earth CandyGram for Mongo