我想点击一个按钮触发事件,但是总是抱错,菜鸟新手求教(红色部分出错)
import wx
class SimpleEditor(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(250,300))
panel=wx.Panel(self,-1)
box=wx.BoxSizer(wx.HORIZONTAL)
self.button = wx.Button(panel, -1, "Enter Question", pos=(50, 200))
#self.Bind(wx.EVT_BUTTON, self.OnMouseDown, self.button)
self.button.SetDefault()
multiText=wx.TextCtrl(panel,-1,
size=(240,180),
style=wx.TE_MULTILINE)
def OnMouseDown(self, event):
frame1 = SimpleEditor2(None, wx.ID_ANY, 'a')
frame1.Show()
class SimpleEditor2(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(250,300))
self.button = wx.Button(panel, -1, "Return", pos=(50, 200))
self.button.SetDefault()
if __name__=='__main__':
app = wx.PySimpleApp()
frame = SimpleEditor(None, wx.ID_ANY, 'Enter Question')
frame.Show()
app.MainLoop()
Traceback (most recent call last):
File "D:\python\py exp\test", line 30, in <module>
frame = SimpleEditor(None, wx.ID_ANY, 'Enter Question')
File "D:\python\py exp\test", line 9, in __init__
self.button.Bind(wx.EVT_BUTTON, self.OnMouseDown, self.button)
AttributeError: 'SimpleEditor' object has no attribute 'OnMouseDown'