Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wxpython Python继承——框架_Wxpython - Fatal编程技术网

Wxpython Python继承——框架

Wxpython Python继承——框架,wxpython,Wxpython,有人能解释一下下面的代码吗。根据我的阅读,Myframe继承了wx.frame,但我不理解的是init方法中给出的下面几行 super(MyFrame, self).__init__(parent, id, title, pos, size, style, name) 代码 这段代码只允许您使用父类的\uuuu init\uuuu()方法。 因此,对于这些特定属性,属性分配代码不必在子类中重复 您也可以

有人能解释一下下面的代码吗。根据我的阅读,Myframe继承了wx.frame,但我不理解的是init方法中给出的下面几行

        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