Here is a sample app. Why
does the program not exit properly?
Running python-2.7.10 (i386/x86_64 build), with wxPython 3.0.2.0
Cocoa, on OS X 10.9.5.
Thanks, Brendan.
import wx
<details class='elided'>
<summary title='Show trimmed content'>···</summary>
On 18/06/2015 9:53 am, Brendan Simon (eTRIX) wrote:
> I've narrowed the issue down to
> wx.ProgressDialog.Update().
>
>
>
> If I do:
>
> dlg = MyProgressDialog(title, message, maximum)
>
> dlg.Destroy()
>
> return True
>
>
>
> then the MainLoop() exits as expected and python exits :)
>
>
>
> If I do:
>
> dlg = MyProgressDialog(title, message, maximum)
>
> dlg.Update(0, new_message)
>
> dlg.Destroy()
>
> return True
>
>
>
> then the MainLoop() never exits :(
>
>
>
> Any ideas why this could be?
>
>
>
> Thanks, Brendan.
#----------------------------------------------------------------------------
class MyProgressDialog(wx.ProgressDialog):
"""My Progress Dialog."""
def __init__(self, *args, **kwargs):
"""Initialise class."""
sty = 0
sty |= wx.PD_APP_MODAL
sty |= wx.PD_AUTO_HIDE
#sty |= wx.PD_SMOOTH
#sty |= wx.PD_CAN_ABORT
#sty |= wx.PD_CAN_SKIP
#sty |= wx.PD_LAPSED_TIMEE
#sty |= wx.PD_ESTIMATED_TIME
#sty |= wx.PD_REMAINING_TIME
kwargs['style'] = kwargs.get('style', sty)
wx.ProgressDialog.__init__(self, *args, **kwargs)
#----------------------------------------------------------------------------
class MyApp(wx.App):
"""My Application."""
def __init__(self, argv):
"""Class constructor."""
self.argv = argv
wx.App.__init__(self, redirect=False)
def OnInit(self):
"""OnInit() method."""
tit = 'Test Title'
msg = "This is a test message. Please wait ..."
max = 100
dlg = MyProgressDialog(title=tit, message=msg, maximum=max)
#dlg.Destroy()
#return True
(keepGoing, skip) = dlg.Update(50, "Half way there ...")
wx.MilliSleep(1000)
dlg.Destroy()
return True
#----------------------------------------------------------------------------
def main_test():
"""Main test function."""
app = MyApp("my arguments")
print "DEBUG: MainLoop() starting."
app.MainLoop()
print "DEBUG: MainLoop() exited."
#----------------------------------------------------------------------------
if __name__ == "__main__":
main_test()