You could import your frame2 file into your frame1 code and instantiate it there.
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
Another way is to use a third class as a wrapper. The buttons in the following code print the contents of the variable from the other class. Also, it is never a good idea to create two or more instances of a GUI at the same time. It can cause confusion with the interaction from the display manager. Use one of instance of wx and separate frames.
import wx
class Test1():
def __init__(self, parent, id, title):
self.ident="Test1 Ident"
self.frame=wx.Frame(None, id, title, size=(170, 100))
self.frame.SetPosition((10, 10))
def exit_button(self, T2):
panel = wx.Panel(self.frame, -1)
exit = wx.Button(panel, -1, 'Exit 1'+T2.ident, (10, 10))
exit.Bind(wx.EVT_BUTTON, self.exit_this, id=exit.GetId())
self.frame.Show(True)
def exit_this(self, event):
self.frame.Close()
class Test2():
def __init__(self, parent, id, title, wrap):
self.ident="Test2"
self.frame=wx.Frame(None, id, title, size=(170, 100))
self.frame.SetPosition((10, 150))
panel = wx.Panel(self.frame, -1)
exit = wx.Button(panel, -1, 'Exit Two-->'+wrap.T1.ident, (10, 10))
exit.Bind(wx.EVT_BUTTON, self.exit_this, id=exit.GetId())
self.frame.Show(True)
def exit_this(self, event):
self.frame.Close()
class Wrapper():
def __init__(self):
app = wx.App()
self.T1=Test1(None, -1, '')
self.T2=Test2(None, -1, '', self)
self.T1.exit_button(self.T2)
app.MainLoop()
W = Wrapper()
woooee
Nearly a Posting Maven
2,454 posts since Dec 2006
Reputation Points: 777
Solved Threads: 714