Disclaimer: I am relatively new to programming, and especially new to Python. I am trying to learn to build a GUI with PyQt5 and I keep receiving the error "Type Error: QApplication(List[str]): not enough arguments" when trying to launch my application... I don't see any arguments that would make sense to use, and the ones that I have tried(that would be valid) then cause it to say " module.init() takes at most 2 arguments (3 given)"
import sys
from PyQt5 import QtWidgets, QtGui
class Main(QtWidgets.QApplication):
def __init__(self):
super(Main, self).__init__()
self.setGeometry(100, 100, 300, 500)
self.setWindowTitle('HelloWorld')
self.setWindowIcon(QtWidget.QIcon('Image.png'))
self.show()
app = QtWidgets.QApplication(sys.argv)
gui = Main()
sys.exit(app.exec_())
Viewing your code I noticed that you are confusing QApplication
with some Widget.
The
QApplication
class manages the GUI application's control flow and main settings. It's Not a Widget.
In your case you could use a widget, for example:
import sys
from PyQt5 import QtWidgets, QtGui
class Main(QtWidgets.QWidget):
def __init__(self):
super(Main, self).__init__()
self.setGeometry(100, 100, 300, 500)
self.setWindowTitle('HelloWorld')
self.setWindowIcon(QtGui.QIcon('Image.png'))
self.show()
app = QtWidgets.QApplication(sys.argv)
gui = Main()
sys.exit(app.exec_())
Note: I have changed self.setWindowIcon(QtWidget.QIcon('Image.png'))
to self.setWindowIcon(QtGui.QIcon('Image.png'))