Here is the code for a progressbar for a urlretrieve download in wx. I do the download work in a different process. It works, but is a bit laggy and unresponsive. As in I cannot move the window around freely. What could be the problem?
- I am usually told not to use threads nor processes. People always point me to twister and event-driven programming (registering callbacks etc.) Threads and processes are a pain to debug and may have different behaviors on different platforms.ychaouche– ychaouche2014-01-30 08:11:22 +00:00Commented Jan 30, 2014 at 8:11
Add a comment |
1 Answer
I'm guessing it's because you're calling this:
self.dloader.parent_conn.recv() That is probably a long running process, so it blocks wxPython's main loop, which makes the UI unresponsive. The typical workaround is to send a message back to the UI from the process or thread telling it to update. You will probably need to use one of wxPython's thread-safe methods to be safe:
- wx.CallAfter
- wx.CallLater
- wx.PostEvent
The canonical article on this topic can be found in the wxPython wiki:
There is also a wiki page on MultiProcessing that you might find helpful: