Reputation: 15
I have a program which shows multiple progress bars in quick succession. It works fine in wxPython 2.8.12.1, but after updating to 3.0.2.0 I've noticed the progress bars all linger until the event handler is complete. The following code reproduces the problem:
import wx
import time
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
button = wx.Button(self, -1, 'Test')
self.Bind(wx.EVT_BUTTON, self._onTestClick, button)
def _onTestClick(self, event):
for i in range(5):
dlg = wx.ProgressDialog('Progress', 'Testing...', 100, self)
for j in range(100):
time.sleep(0.01)
dlg.Update(j)
dlg.Destroy()
event.Skip()
if __name__ == '__main__':
app = wx.App(0)
frame = MyFrame()
frame.Show()
app.MainLoop()
I've tried adding wx.Yield() after the Destroy() call, but that doesn't help. Does anyone know how I can get the old dialogs to disappear sooner?
Upvotes: 1
Views: 54
Reputation: 6206
The difference is probably due to the MSW port switching to a native progress dialog by default, and the fact that native dialogs are not a true wx.Dialog
but just wrappers around a native API function call. You can use wx.GenericProgressDialog
to get a true wx.Dialog
version, which should have the old behavior with regard to object destruction.
Upvotes: 1