我是 wxpython 和 stackoverflow 的新手,如果我犯了任何愚蠢的错误,请多多包涵。
框架1:
import wx
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1PANEL1, wxID_FRAME1SLIDER1,
wxID_FRAME1STATICTEXT1,
] = [wx.NewId() for _init_ctrls in range(5)]
class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(710, 314), size=wx.Size(483, 276),
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
self.SetClientSize(wx.Size(467, 237))
self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(467, 237),
style=wx.TAB_TRAVERSAL)
self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label=u'ClickMe',
name='button1', parent=self.panel1, pos=wx.Point(312, 112),
size=wx.Size(136, 72), style=0)
self.button1.SetForegroundColour(wx.Colour(64, 0, 64))
self.button1.SetBackgroundColour(wx.Colour(128, 255, 255))
self.button1.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
self.button1.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
u'Gill Sans Ultra Bold'))
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
id=wxID_FRAME1BUTTON1)
self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
label=u'HelloWorld', name='staticText1', parent=self.panel1,
pos=wx.Point(168, 16), size=wx.Size(130, 29), style=0)
self.staticText1.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL,
False, u'Ubuntu Mono'))
self.slider1 = wx.Slider(id=wxID_FRAME1SLIDER1, maxValue=100,
minValue=0, name='slider1', parent=self.panel1, pos=wx.Point(64,
144), size=wx.Size(100, 24), style=wx.SL_HORIZONTAL, value=0)
def __init__(self, parent):
self._init_ctrls(parent)
def OnButton1Button(self, event):
event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = create(None)
frame.Show()
app.MainLoop()
框架2:
import wx
def create(parent):
return Frame1(parent)
[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1PANEL1, wxID_FRAME1SLIDER1,
wxID_FRAME1STATICTEXT1,
] = [wx.NewId() for _init_ctrls in range(5)]
class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(710, 314), size=wx.Size(483, 276),
style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
self.SetClientSize(wx.Size(467, 237))
self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,
pos=wx.Point(0, 0), size=wx.Size(467, 237),
style=wx.TAB_TRAVERSAL)
self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label=u'ClickMe',
name='button1', parent=self.panel1, pos=wx.Point(312, 112),
size=wx.Size(136, 72), style=0)
self.button1.SetForegroundColour(wx.Colour(64, 0, 64))
self.button1.SetBackgroundColour(wx.Colour(128, 255, 255))
self.button1.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
self.button1.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
u'Gill Sans Ultra Bold'))
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
id=wxID_FRAME1BUTTON1)
self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
label=u'HelloWorld', name='staticText1', parent=self.panel1,
pos=wx.Point(168, 16), size=wx.Size(130, 29), style=0)
self.staticText1.SetFont(wx.Font(20, wx.SWISS, wx.NORMAL, wx.NORMAL,
False, u'Ubuntu Mono'))
self.slider1 = wx.Slider(id=wxID_FRAME1SLIDER1, maxValue=100,
minValue=0, name='slider1', parent=self.panel1, pos=wx.Point(64,
144), size=wx.Size(100, 24), style=wx.SL_HORIZONTAL, value=0)
def __init__(self, parent):
self._init_ctrls(parent)
def OnButton1Button(self, event):
event.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = create(None)
frame.Show()
app.MainLoop()
我想链接这些框架,以便当我单击 frame1 中的按钮时, frame2 打开。我想用正确的方法绑定按钮以将控件传递给另一个框架。