Hi All,
I have a program that uses several different layouts, which all seems to work fine apart from in one situation. I am using SetSizer() to change the layout when buttons are pressed, which is working fine apart from when I want to set a ‘Please Wait’ layout whilst a calculation is taking place. At this point, the current layout is shown whilst the calculation takes place (calc can be anywhere between few secs and couple of mins.), and then the ‘Finished’ layout is shown missing out the ‘Please Wait’ layout. I’ve attached some example code to show roughly what I’m trying to do. Am I implementing this in the wrong way?
Thanks for any help in advance.
sample.rtf (1.63 KB)
You’ll want to show the “Please Wait” layout BEFORE you start the calculation. The calculation needs to go into a thread or it will make the GUI unresponsive. When the thread finishes, you can tell the GUI to update to the “finished” layout using wx.CallAfter or wx.PostEvent. See LongRunningTasks - wxPyWiki or wxPython and Threads - Mouse Vs Python for more information.
···
On Friday, June 15, 2012 4:05:33 AM UTC-5, tsenate wrote:
Hi All,
I have a program that uses several different layouts, which all seems to work fine apart from in one situation. I am using SetSizer() to change the layout when buttons are pressed, which is working fine apart from when I want to set a ‘Please Wait’ layout whilst a calculation is taking place. At this point, the current layout is shown whilst the calculation takes place (calc can be anywhere between few secs and couple of mins.), and then the ‘Finished’ layout is shown missing out the ‘Please Wait’ layout. I’ve attached some example code to show roughly what I’m trying to do. Am I implementing this in the wrong way?
Thanks for any help in advance.
Hi Mike,
Thanks for the info. I found your blog on threading when googling the wx.Callafter’s that GadgetSteve suggested and managed to implement it using your example.
Many thanks,
Tommy
···
On Monday, 18 June 2012 16:21:24 UTC+1, Mike Driscoll wrote:
On Friday, June 15, 2012 4:05:33 AM UTC-5, tsenate wrote:
Hi All,
I have a program that uses several different layouts, which all seems to work fine apart from in one situation. I am using SetSizer() to change the layout when buttons are pressed, which is working fine apart from when I want to set a ‘Please Wait’ layout whilst a calculation is taking place. At this point, the current layout is shown whilst the calculation takes place (calc can be anywhere between few secs and couple of mins.), and then the ‘Finished’ layout is shown missing out the ‘Please Wait’ layout. I’ve attached some example code to show roughly what I’m trying to do. Am I implementing this in the wrong way?
Thanks for any help in advance.
You’ll want to show the “Please Wait” layout BEFORE you start the calculation. The calculation needs to go into a thread or it will make the GUI unresponsive. When the thread finishes, you can tell the GUI to update to the “finished” layout using wx.CallAfter or wx.PostEvent. See http://wiki.wxpython.org/LongRunningTasks or http://www.blog.pythonlibrary.org/2010/05/22/wxpython-and-threads/ for more information.