0

I am working on some software for the company that I work for. I am using wx for the GUI. I basically have this: When the program is busy or loading, I create a wx.BusyInfo object. But, sometimes, while this busy info box is still visible, and I need to print an error message to the user, but that MessageDialog actually is popping up underneath the BusyInfo box. Why? Is there a way to make the error show on top of the BusyInfo? I tried the wx.STAY_ON_TOP option, and it did not work.

I need it to work this way because, my classes are getting convoluted, and I don't want to have to delete the BusyInfo, show the error, then recreate the BusyInfo; it would be easier for my code, to just have the MessageDialog error show on top of the BusyInfo box.

Thanks.

Here is some sample code for what I am trying to do:

# myWindow is the main Window or Frame
wx.BusyInfo("Loading, please wait ...", myWindow)
wx.MessageDialog(myWindow, "Error message", "Error!", style = wx.OK | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
Erik343
  • 323
  • 4
  • 14

1 Answers1

0

After lots of google searches and research I found out how to solve the issue! First, instead of using wx.BusyInfo I use PyBusyInfo (I found the code here: https://searchcode.com/codesearch/view/63249201/). This is because, wx.BusyInfo is not actually inherited from a wx.Window class, but PyBusyInfo is; we need the busy's frame because we will pass it into wx.MessageDialog. Then, I just pass in the self._infoFrame as the parent into the wx.MessageDialog. Thats it.

First, I added this method to PyBusyInfo class:

def getFrame(self):
    return self._infoFrame

Then, I do this code to make it work properly with the error message ABOVE the Busy Info box:

myBusy = PyBusyInfo("Loading, please wait ...", myParentWindow)
wx.MessageDialog(myBusy.getFrame(), "Error message", "Error!", style = wx.OK | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)

This was a tough issue to solve, but this information should help other people who run across the same problem.

Erik343
  • 323
  • 4
  • 14