Returning data from a non dialog window

I have two wx.Frames. Frame1 is the main frame for the application, while Frame2 is a configuration window that helps the userload, modify and save paremeters for the application.
That Frame1 calls Frame2.Show() followed by Frame2.GetConfig() which returns dataset of parameters I’d like to 'Show() the configuration frame and when it is closed, call something like Frame2.GetParams() which returns the configuration. The problem I’m finding is that Frame2.Show() returns immediately and Frame2.GetParams() gets called before the user has processed the form so the GetParams() returns an empty dataset. How do I make the Show() wait until the form is closed?

Thanks,
Leif

WOW! This situation was greatly helped by sibclassing a dialog and designing the dialog window how i wanted my property details to look, then after the ShowModal() returned, I could call a function of my class that returned the data.

by what I understand show a Dialoge in the init of your main Frame b e f o r e calling super() and then customize your Frame according to the return of the Dialog; an even more interesting exercise (and probably more pythonic?) would be using a metaclass construct and find out whether wx doesn’t get screwed up…

I not any kind of programmer but I normally use properties something like this:

def _getMainForm(self):
        return getattr(self, "_MainForm", None)
def _setMainForm(self, val):
        self._MainForm = val
MainForm = property(_getMainForm, _setMainForm)

and the set a value to to the MainForm.somevar

import wx

class Gui(wx.Frame):

    def __init__(self):
        super().__init__(
            None,
            title='Demo modeless dialog',
            style=wx.CAPTION | wx.CLOSE_BOX | wx.RESIZE_BORDER)

        panel = wx.Panel(self)
        vbox = wx.BoxSizer(wx.VERTICAL)

        #   Dialog
        vbox.Add(
            wx.Button(panel, id=2, label='Dialog'),
            0, wx.LEFT|wx.TOP|wx.RIGHT, 10)

        panel.SetSizerAndFit(vbox)

        #   event bindings
        self.Bind(wx.EVT_CLOSE, self.on_quit)
        self.Bind(wx.EVT_BUTTON, self.event_button)

        self.sb = self.CreateStatusBar(1, style=wx.SB_FLAT)
        self.Show()

    def __del__(self):
        print(f'id {id(self)} {__class__}: __del__')

    def event_button(self, evt):
        if evt.GetId() == 2:
            self.dialog()

    def dialog(self, result=None):
        if result:
            print(result)
        else:
            Dialog(self, 'dialog')

    def on_quit(self, evt):
        self.Destroy()

class Dialog(wx.Dialog):

    def __init__(self, parent, ret_method):
        super().__init__(
            parent,
            title='Dialog')
        print('Init dialouge')

        self.retmet = eval(f'parent.{ret_method}')     # return method

        panel = wx.Panel(self)

        #   button
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(wx.Button(panel, label='dialog button'))

        panel.SetSizer(hbox)

        #   event bindings
        self.Bind(wx.EVT_BUTTON, self.event_button)
        self.Bind(wx.EVT_CLOSE, self.on_quit)
        self.Show()

    def __del__(self):
        print(f'id {id(self)} {__class__}: __del__')

    def event_button(self, evt):
        retc = wx.ID_OK
        parm = (1, 2, 3)
        self.retmet((retc, parm))
        self.Destroy()

    def on_quit(self, evt):
        print('quit dialog')
        self.Destroy()

class WxApp(wx.App):

    def __init__(self):
        try:
            super().__init__(filename=None)       #   with console
        except TypeError:
            print('Init error at wxApp')
        else:
            # set 'English' as language
            locale = wx.Locale()
            locale.Init(language=wx.LANGUAGE_ENGLISH)
            # self.Init()                                 # initialize the inspection tool
            frame = Gui()
            self.SetTopWindow(frame)
            self.MainLoop()

    def __del__(self):
        print(f'id {id(self)} {__class__}: __del__')

if __name__ == "__main__":
    WxApp()