Wxpython Python继承——框架
有人能解释一下下面的代码吗。根据我的阅读,Myframe继承了wx.frame,但我不理解的是init方法中给出的下面几行Wxpython Python继承——框架,wxpython,Wxpython,有人能解释一下下面的代码吗。根据我的阅读,Myframe继承了wx.frame,但我不理解的是init方法中给出的下面几行 super(MyFrame, self).__init__(parent, id, title, pos, size, style, name) 代码 这段代码只允许您使用父类的\uuuu init\uuuu()方法。 因此,对于这些特定属性,属性分配代码不必在子类中重复 您也可以
super(MyFrame, self).__init__(parent, id, title,
pos, size, style, name)
代码
这段代码只允许您使用父类的
\uuuu init\uuuu()
方法。因此,对于这些特定属性,属性分配代码不必在子类中重复 您也可以这样做:
wx.Frame.__init__() # just an example, args omitted
但是,您正在对父类名称进行硬编码,代码变得不那么灵活
旁白:
在Python 3中,对
super()
的调用简化为:
super().__init__() # just an example, args omitted
super().__init__() # just an example, args omitted