changepanel0.py
“””
四个不同的文件,名为changpanel0.py changepanel1.py changepanel2.py changepanel3.py
“”“
import wx
from changepanel1 import PanelOne
class My_App(wx.App):
def OnInit(self):
self.frame = My_Frame()
self.frame.Show()
self.SetTopWindow(self.frame)
return True
class My_Frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,"My Frame",size = (280, 500))
self.panel1 = PanelOne(self)
self.panel1.Show()
self.plst = []
print self.plst
if __name__ == '__main__':
app = My_App(False)
app.MainLoop()
changepanel1.py
import wx
from changepanel2 import PanelTwo
class PanelOne(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent=parent)
basicLabel = wx.StaticText(self, -1, "panel 1",pos=(80,150))
next = wx.Button(self,-1,"Next",pos=(50,200))
back = wx.Button(self,-1,"Back",pos=(150,200))
self.Bind(wx.EVT_BUTTON,self.OnNext,next)
self.Bind(wx.EVT_BUTTON,self.OnBack,back)
def OnNext(self,event):
self.Hide()
self.GetParent().plst.append(self)
tmp = PanelTwo(self.GetParent())
tmp.Fit()
tmp.Show()
print self.GetParent().plst
def OnBack(self,event):
tmp = self.GetParent().plst.pop()
tmp.Fit()
tmp.Show()
self.Destroy()
changepanel2.py
import wx
from changepanel3 import PanelThree
class PanelTwo(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent=parent)
basicLabel = wx.StaticText(self, -1, "panel 2",pos=(80,150))
next = wx.Button(self,-1,"Next",pos=(50,200))
back = wx.Button(self,-1,"Back",pos=(150,200))
self.Bind(wx.EVT_BUTTON,self.OnNext,next)
self.Bind(wx.EVT_BUTTON,self.OnBack,back)
def OnNext(self,event):
self.Hide()
self.GetParent().plst.append(self)
tmp = PanelThree(self.GetParent())
tmp.Fit()
tmp.Show()
print self.GetParent().plst
def OnBack(self,event):
tmp = self.GetParent().plst.pop()
tmp.Fit()
tmp.Show()
print self.GetParent().plst
self.Destroy()
changepanel3.py
import wx
class PanelThree(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent=parent)
basicLabel = wx.StaticText(self, -1, "panel 3",pos=(80,150))
next = wx.Button(self,-1,"Next",pos=(50,200))
back = wx.Button(self,-1,"Back",pos=(150,200))
self.Bind(wx.EVT_BUTTON,self.OnNext,next)
self.Bind(wx.EVT_BUTTON,self.OnBack,back)
def OnNext(self,event):
self.Close()
def OnBack(self,event):
tmp = self.GetParent().plst.pop()
tmp.Fit()
tmp.Show()
print self.GetParent().plst
self.Destroy()
你好,我想打开多个面板,所以我使用一个列表进行维护,还有其他解决方案可以做同样的工作吗?
答案 0 :(得分:0)