#!/usr/bin/python
import MainPanel
import wx
########################################################################
class OtherFrame(wx.Frame):##open PDB frame
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, wx.ID_ANY, "Secondary Frame")
panel = wx.Panel(self)##create panel
chain = wx.Button(panel, label = "OK", pos=(100,80),size=(53,25))##button create
self.Bind(wx.EVT_BUTTON,self.getchain,chain)##bind event to button go to getchain method
def getchain(self,event):
global flag
flag = 1
import OtherFrame
#######
class MainPanel(wx.Panel):##main frame
""""""
#----------------------------------------------------------------------
def __init__(self, parent, size = (5000,5000)):
"""Constructor"""
wx.Panel.__init__(self, parent=parent, size = (5000,5000))
self.frame = parent
Publisher().subscribe(self.showFrame, ("show.mainframe"))
def showFrame(self, msg):
#------------------------------------------------------------------
def createfigure():
OtherF = OtherFrame.OtherFrame()
OtherF.getchain()
print flag
首先,由于代码超过 1000 行,我已经大大缩短了我的代码。我想要做的是获取声明的变量getchain
并在def createfigure
. 他们来自不同的阶层。目前我收到错误getchain() takes exactly 2 arguments (1 given)
有人可以告诉我哪里出错了,以及如何获取我使用的变量def getchain(self,event)
并在其中使用它们def createfigure