in reply to Server with GUI
Since you are new to Perl, I will give you some tips. In any GUI, if you run a while loop( or sleep ) as you do in your code, you will interfere with the GUI's eventloop, which is the line $app->MainLoop; That will make the GUI freeze unless you manually update the mainwindow everytime thru the loop. You just can't mix conventional Perl code with GUI code, and expect it to run.
You can run a network while loop with a GUI front end, but the network loop must be in a separate thread. This however, is generally not a problem with GUI's because almost every GUI toolkit has a fileevent or IO watch method, which allows the GUI to watch the network without a while loop. I googled for it, and was surprised to read that Wxwidgets has no filehandle watch. See AnyEvent for a workaround. Maybe a Wx guru knows a better way.
To show how it should work, using Tk , see Re: hanged In Tk-socket program. In that server, I make the socket before the GUI pops up, and use a fileevent to handle incoming connections. This is probably the simplest example possible.
You might want to switch to Tk if you don't understand how Wx or GUI's work. For more complex Tk server-client pairs, see ztk-enchat encrypted server client and Tk encrypted echoing-chat client and server
Once you get the idea of how it is supposed to work with Tk, then you can go back and try to do the same thing with Wx. Sockets are not intuitively obvious to make run correctly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Server with GUI
by gg4000 (Novice) on May 28, 2012 at 17:15 UTC | |
by zentara (Cardinal) on May 28, 2012 at 19:09 UTC | |
by gg4000 (Novice) on May 28, 2012 at 19:32 UTC | |
by zentara (Cardinal) on May 29, 2012 at 09:21 UTC | |
by Anonymous Monk on May 29, 2012 at 09:30 UTC | |
|
Re^2: Server with GUI
by gg4000 (Novice) on May 29, 2012 at 23:41 UTC | |
by zentara (Cardinal) on May 30, 2012 at 10:40 UTC | |
by gg4000 (Novice) on May 30, 2012 at 16:16 UTC | |
by gg4000 (Novice) on Jun 01, 2012 at 23:46 UTC | |
by zentara (Cardinal) on Jun 02, 2012 at 10:28 UTC | |
by gg4000 (Novice) on Jun 02, 2012 at 22:38 UTC | |
| |
by gg4000 (Novice) on May 30, 2012 at 10:34 UTC |