Typeerror: super() takes at least 1 argument (0 given) error occurred when writing inheritance subclass
Source code (perfect to run in python3)
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI() #Interface drawing is given to the InitUi method
The reason is super ()__ init__() Function is supported in python3, which is correct, but it will cause problems in python2
If you want to inherit the construction method of the parent class in Python 2, you need to pass in the super parameter: Super (example, self)__ init__();
In python2, it should be written as follows:
class Example(QWidget):
def __init__(self):
super(Example,self).__init__()
self.initUI() #Interface drawing is given to the InitUi method
Similar Posts:
- [Solved] pyqt5 ‘QWidget’ object has no attribute ‘setCentralWidget’
- qt *undefined reference to `vtable for xxx solution programme
- Python: __ new__ Method and the processing of typeerror: object() takes no parameters
- [design and development] Python learning notes – Super () argument 1 must be type, not classobj
- Python Error-TypeError:takes 2 positional arguments but 3 were given
- How to Solve Python Error : **kwargs and takes 1 positional argument but 2 were given
- Fatal error: Call-time pass-by-reference has be…
- Python bug problems and solutions sorted out in recent days
- How to Solve setSupportActionBar() Method Error