Search code examples
dialogwxpythonframe

wxPython wx.Frame with wx.Dialog effect


I want to have a wx.Frame that has the effect that the wx.Dialog has, that you cant unfocus it until it closes itself, makes it above all other. I need to use wx.Frame and not wx.Dialog because when using wx.Dialog and calling the dialog.ShowModal() it doesn't continue the code after it until the answer. I tried this:

self.Bind(wx.EVT_KILL_FOCUS,self.unfocus)

def unfocus(self,e):
    self.SetFocuse()

But it didn't do it.


Solution

  • What you are looking for is MakeModal(). So in your frame's class, you would call something like this:

    self.MakeModal(True)
    

    This only applies to wxPython classic. If you happen to be using Phoenix, then you'll want to take a look at the Migration Guide as MakeModal was removed: