title: wxPython best way to pass back and forth a set of parameters from frame to dialog
body: <p>I'm new to wxPython programming and what I would ideally do is have parameters that can be set open in custom dialog (ParameterDialog) with text boxes that have the default values already filled in to the default parameter values set in ImageFrame. Then passing back the changed values or all values in the ParameterDialog Dialog frame by pressing OK or closing/exiting the dialog frame. What is the best way to go about this? Or is there a better solution to this than using a dialog pop-up frame. </p>
  
  <p>Also I have read that modeless windows open using Show() instead of ShowModal(). Whenever I use Show(), instead of ShowModal() nothing happens. I've cut most the code out below but should give a mostly minimal example of what I want and have been able to piece together.</p>
  
  <pre><code>import os
  import pprint
  import random
  import wx
  import numpy as np
  import matplotlib
  matplotlib.use('WXAgg')
  from matplotlib.figure import Figure
  from matplotlib.backends.backend_wxagg import \
      FigureCanvasWxAgg as FigCanvas, \
      NavigationToolbar2WxAgg as NavigationToolbar
  
  class ImageFrame(wx.Frame):
      """ The main frame of the application
      """
      def __init__(self):
          wx.Frame.__init__(self, None, -1, 'title')
  
          self.param1 = 10
          self.param2 = 0.2
  
          self.panel = wx.Panel(self)        
  
          self.button_set_parameters = wx.Button(self.panel, -1, "Set Parameters")
          self.Bind(wx.EVT_BUTTON, self.on_set_parameters, self.button_set_parameters)
  
          #
          # Layout with box sizers
          #
          self.vbox = wx.BoxSizer(wx.VERTICAL)
          self.vbox.Add(self.button_set_parameters, 0, border=3, flag=flags)
          self.panel.SetSizer(self.vbox)
          self.vbox.Fit(self)
  
      def on_set_parameters(self, event):
          dia = ParameterDialog()
          res = dia.ShowModal() # Use Show() here to allow edit window to remain open while using rest of application
  
          # Ideally the code below would run on ok or on closing the dialog?? Is this possible or better way to do this? Or is Checking everytime a change is made to a textbox possible and a better way?
          if res == wx.ID_CLOSE or res == wx.ID_EXIT or res == wx.ID_OK:
              self.param1 = dia.param1.GetValue()
              self.param2 = dia.param2.GetValue()
          dia.Destroy()
          return True
  
      def on_exit(self, event):
          self.Destroy()
  
  
  class ParameterDialog(wx.Dialog):
      """
      Used to set the parameters for running.
      """
      def __init__(self):
          wx.Dialog.__init__(self, None, title="Parameters")
  
          self.static_text_param1 = wx.StaticText(self, label="Param1:")
          # Defualt value of 10 displayed in the textbox here as param1 but would need passed in from the ImageFrame class.
          self.param1 = wx.TextCtrl(self, size=(100, -1))        
  
          self.static_param2 = wx.StaticText(self, label="Param2:")
          self.param2 = wx.TextCtrl(self, size=(100, -1))        
  
          # Setup up Sizer
          flags = wx.ALIGN_LEFT | wx.ALL | wx.ALIGN_CENTER_VERTICAL
          sizer_vert =  wx.BoxSizer(wx.VERTICAL)
  
          sizer_horz = wx.BoxSizer(wx.HORIZONTAL)
          sizer_horz.Add(self.static_text_param1, 0, border=3, flag=flags)
          sizer_horz.Add(self.param1, 0, border=3, flag=flags)
          sizer_vert.Add(sizer_horz, 0, flag = wx.ALIGN_LEFT | wx.TOP)
  
          sizer_horz = wx.BoxSizer(wx.HORIZONTAL)
          sizer_horz.Add(self.static_param2, 0, border=3, flag=flags)
          sizer_horz.Add(self.param2, 0, border=3, flag=flags)
          sizer_vert.Add(sizer_horz, 0, flag = wx.ALIGN_LEFT | wx.BOTTOM)
  
          self.SetSizer(sizer_vert)
          sizer_vert.Fit(self)
  
  
  if __name__ == '__main__':
      app = wx.PySimpleApp()
      app.frame = ImageFrame()
      app.frame.Show()
      app.MainLoop()
  </code></pre>