编程技术记录

世界你好!

我用wxGlade生成Python的UI代码,但添加监听EVT_CLOSE事件代码时,运行崩溃

Traceback (most recent call last):
  File "/Users/zxs.zl/Desktop/Yan/github/XcodeBuildPyUI/zlBuild/app.py", line 16, in OnInit
    self.frame = mainFrame(None, wx.ID_ANY, "")
  File "/Users/zxs.zl/Desktop/Yan/github/XcodeBuildPyUI/zlBuild/mainFrame.py", line 38, in __init__
    self.Bind(wx.EVT_CLOSE, self.onWindowClose, self.frame)
AttributeError: 'mainFrame' object has no attribute 'frame'

生成的代码部分:

class mainFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: mainFrame.__init__
       部分代码如下

        self.Bind(wx.EVT_BUTTON, self.onClickBuildLibButton, self.buildLibButton)
        self.Bind(wx.EVT_CLOSE, self.onWindowClose, self.frame)
        # end wxGlade

将生成的代码self.frame改为self,运行正常

# self.Bind(wx.EVT_CLOSE, self.onWindowClose, self.frame)
self.Bind(wx.EVT_CLOSE, self.onWindowClose, self)

发表回复

© Beli. All Rights Reserved.