I'm following an online tutorial (for PyQt4, I have PyQt5). I have typed the exact code, yet it returns many errors. One of them is illegal target for variable annotation. I've got no idea on how to remove this as I've only learnt very basic python.
I tried reading the documentation but failed to understand how to solve this problem.
import sys
from PyQt5 import QtGui
class Window(QtGui.QMainWindow):
def__init__(self):
super(Window, self).__init__()
self.setGeometry(50, 50, 500, 300)
self.setWindowTitle("PyQt Tuts!")
self.setWindowIcon(QtGui.QIcon('Screenshot (967).png'))
self.show()
def home(self):
btn = QtGui.QPushButton("Quit", self)
btn.clicked.connect(QtCore.QCoreApplication.instance().quit)
btn.resize(100, 100)
btn.move(100, 100)
self.show()
def run():
app = QtGui.QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())
run()
The expected output would be a push button which terminates the program.