Reputation: 3153
I am working on a project coded in python with GUI in Wxpython for last 3 sleepless night now I got struck.Actually inside main parent frame I am executing a new subframe in another thread all I want is to stop further code execution until its subframe has done its work and closed. I have tried using threading.Thread.join() method but it does not seems to work efficiently and after the Closing of subframe the Main Parent Frame Hangs. Is there any efficient method to do this thing?
Upvotes: 0
Views: 490
Reputation: 33071
Use a wx.Dialog instead of a sub-frame and its ShowModal() method to stop the execution of the main frame. Technically, you could also use the frame's MakeModal() method for a similar effect, but I think using a dialog makes more sense.
By the way, when using threads with wxPython (or any GUI toolkit), you MUST use the toolkit's threadsafe methods to update the GUI. You should not try to directly access a GUI element from a thread as that is undefined behavior. Instead, use wx.CallAfter, wx.CallLater or wx.PostEvent as they are wxPython's threadsafe methods.
See also:
Upvotes: 4