Search code examples
pythonwxpython

wxPython BusyInfo widget no longer works


In my wxPython GUIs, the wx.BusyInfo widget no longer works. I'm working on OSX, and I recently upgraded to El Capitan.

This simple code below doesn't work anymore with either of the wx versions that I have available ('3.0.2.0' or '2.9.2.4'). As far as I can tell, wx.BusyInfo simply no longer shows up. Unfortunately, I don't know exactly when the widget stopped appearing.

class MyFrame(wx.Frame):

    def __init__(self, parent, title):
        super(MyFrame, self).__init__(parent, size=(450, 350))
        self.panel = wx.Panel(self)

        btn = wx.Button(self.panel, wx.ID_ANY, "Do thing")
        self.Bind(wx.EVT_BUTTON, self.do_thing)
        self.Centre()
        self.Show()

    def do_thing(self, event):
        wait = wx.BusyInfo('Please wait...')
        time.sleep(5)
        del wait

Any ideas on the cause or solution to this problem?


Solution

  • It looks like something may have changed with respect to when the paint events for the busy info window are processed. What you are seeing is simply that the paint event is not being delivered until after your sleep is done. If you give it a chance to be painted before you block with your busyness (such as calling wx.Yield(True) before) then you should see it working like with earlier versions of OSX. Better yet, if you can organize your busy task so it periodically yields then the system can do things like keep the busy info panel updated and show a real busy cursor instead of the spinning beachball.