|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
loops in gui
Can anyone show me an example of wxPython with a while loop in it? cause i have been tring to add a while loop in one of my programs using wxPython.. but it stops the gui from loading.... i tried using threading but every time i am about to read about it.. i get disturbed by something or someone
![]()
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#2
|
|||
|
|||
|
Where or why are you trying to use a while loop?
Generally, with GUI programs, they are event-driven, so you respond to button clicks, mouse movements, etc. If you put a while loop in one of these methods, it wouldn't stop the GUI from loading - it would stop it from updating for a ... while. ![]() If you are trying to have something happen all the time while your GUI is running, make a method for the action, and set a timer to trigger the method every so often. In other words, a While loop is probably not the best solution to whatever you are trying to do in a GUI environment... |
|
#3
|
||||
|
||||
|
Quote:
Not nececeraly.. i was using socket.recv( ) in a while loop to get socket data.. didnt know what was going on cause it didnt want to load anything.... then i search around and i find Code:
wxSocketClient::Connect bool Connect(wxSockAddress& address, bool wait = TRUE) Connects to a server using the specified address. If wait is TRUE, Connect will wait until the connection completes. Warning: This will block the GUI. I whent in to wxwidget irc chan and as you can see this class funtion ( wxSocketclient:Connect ) is the same as using the low level socket module... The only option i got is using threaded socket.. ( but dont know how yet, this is why i asked for a sample ) or select, or twisted.. And at the moment i dont want to learn twisted... so if anyone has an example using threading.. i would like to see it if its kool |
|
#4
|
|||
|
|||
|
This link should get you started:
http://wiki.wxpython.org/index.cgi/LongRunningTasks Dave - The Developers' Coach |
|
#5
|
||||
|
||||
|
Quote:
Ya im going to have to deal with this one then. thanx |
|
#6
|
||||
|
||||
|
Forget the threading, looking at the link Dave supplied it looks like all you have to di is call the wxYield() function inside your loop to force the window to refesh and it should work fine..
Mark. |
|
#7
|
||||
|
||||
|
Nah you will just get an error about wxYeild being called recursively
|
|
#8
|
||||
|
||||
|
Quote:
You can get round this by calling wxGetApp().wxYield(True). Th global function wxGetApp returns the wxApp object, and the wxYield method takes a boolean parameter that makes it only yield when not called recursively. From the docs: Quote:
Dave - The Developers' Coach |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > loops in gui |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|