wxPython doesn't really have any mechanism for determining whether a MessageDialog is open. What you can do instead is manually keep track of whether a dialog is open.
If you open the MessageDialog using ShowModal
, then the ShowModal
call will return when the dialog is closed. You could use a flag which is set to True
before the call to ShowModal
and False
afterwards, i.e. something like:
self.is_dialog_open = True
dialog.ShowModal()
self.is_dialog_open = False
The method called by your wx.Timer can then use self.is_dialog_open
to determine whether the dialog is open.
Depending on how your application is structured, you might want to store this flag in some other object instead of self
.
(I'm not making any guarantee that this code isn't prone to race conditions. If your timer happens to check whether a dialog is open just after ShowModal()
returns but before self.is_dialog_open
is set back to False
, then your timer will think that the dialog is open when it in fact has just been closed. Hopefully this won't be a serious problem for you.)