求问:mypython的小例子AttributeError: 'SimpleEditor' object has no attribute 'OnMouseDown'

我想点击一个按钮触发事件,但是总是抱错,菜鸟新手求教(红色部分出错)

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'

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值