I find that .CenterOnParent() does not always work as I would expect. Here is a code snippet:
dlg = wx.MessageDialog(self.GetTopLevelParent(), msg, caption=header, style=wx.YES_NO)
dlg.CenterOnParent()
try:
result = dlg.ShowModal()
finally:
dlg.Destroy()
In this case self is a already a subclass of wx.Frame so the self.GetTopLevelParent() is unneeded, but does not make a difference. What I am seeing is that Message dialog is placed on the same screen as the existing TopLevel, but not on top of it. It seems in some places in my code window.CenterOnParent() does its job but not always. FWIW, at the moment I am using wx 4.1.1 w/Python 3.9.1 on a Mac.
Brian