【发布时间】:2015-08-04 14:21:24
【问题描述】:
我正在尝试从另一个类 (prefWindow) 调用驻留在一个类 (Main) 中的方法 (OnOpen)。我正在使用 wx python 作为 GUI。 问题是每当我尝试使用这个 parent.OnOpen 时,它都会出错,说它没有定义。 我绝不是python专家,最近才开始。
class Main(wx.Frame):
def __init__(self, *args, **kwargs):
super(Main, self).__init__(*args, **kwargs)
self.initUI()
def initUI(self):
*more code here*
def OnOpen(self,e):
global dirname
dlg = wx.FileDialog(self, "Choose a file to open", self.dirname, "", "*.apk", wx.OPEN) #open the dialog box to open file
class prefWindow(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self, parent, id)
self.initPref()
def initPref(self):
browseBtn = wx.Button(panel, -1, "Browse")
self.Bind(wx.EVT_BUTTON, parent.OnOpen, browseBtn)
谢谢。
【问题讨论】:
-
您的代码 sn-p 中也缺少一些东西...