Search code examples
python-3.xwxpython

How can I use wx.GenericMessageDialog?


Would anyone please help me understand how to use "wx.GenericMessageDialog.init" properly so that it will appear as an another frame?

I have a main frame and I would like to be able to change msg1 from the main frame.

class AnotherFrame(wx.Frame):

    def __init__(self, msg1):

        wx.GenericMessageDialog.__init__(self, None, msg1, caption="title",style=wx.YES_NO | wx.ICON_QUESTION)

Solution

  • As far as I know, there's no way to have a generic message dialog behave like a frame. Here is a typical implementation:

    with wx.GenericMessageDialog(self, "message", "caption", style=wx.YES_NO | wx.ICON_QUESTION) as dialog:
        dialog.ShowModal()
    

    If you don't want it to be modal I would suggest subclassing wx.Dialog and calling dialog.Show() instead of dialog.ShowModal()