Hi
How can I pass values between two frames. I have text control in first frame . If I type something on the text control and then when I press ok. My second frame opens and in that frame I have to get the value I typed on first frame and then It should put in the text control on the second frame. How can I do that.
Here is my sample code.
import wx
import os, sys
import string
import re
import wx.lib.dialogs
···
#########################
class MyFrame1(wx.Frame):
def init(self, parent, id, title):
wx.Frame.init(self, parent,-1,title,wx.DefaultPosition,wx.Size(450,450))
self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
self.rb1 = wx.RadioButton(self.mainpa,10,"Analyze",wx.Point(20,40),style = wx.RB_GROUP)
self.Bind(wx.EVT_RADIOBUTTON, self.OnOk,id =10)
self.text1 = wx.TextCtrl(self.mainpa,-1,"",(140,40),(155,-1))
b2 =wx.Button(self.mainpa,30,'Ok',(300,340))
self.Bind(wx.EVT_BUTTON,self.OnOk,b2)
cancel_bt2 =wx.Button(self.mainpa,-1,'Cancel',(200,340))
self.Bind(wx.EVT_BUTTON,self.OnCancel,cancel_bt2)
def OnOk(self,event):
if (self.rb1.GetValue()== True):
self.dlg = MyFrame2(self,-1)
self.dlg.Show(True)
def OnCancel(self,event):
self.Close()
class MyFrame2(wx.Frame):
def init(self, parent, id, title=“Second Frame”):
wx.Frame.init(self, parent,-1,title,wx.DefaultPosition,wx.Size(450,450))
self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)
self.stext1 = wx.StaticText(self.mainpa,-1,"File Name",(20,10))
self.text2 = wx.TextCtrl(self.mainpa,-1,"",(120,10),(155,-1))
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame1(None, -1, ‘First Frame’)
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()