Выдает ошибку:
File "main.py", line 10, in __init__
self.menubar = QMainWindow.menuBar()
TypeError: menuBar(self): first argument of unbound method must have type 'QMainWindow'
Как исправить ?
import sys
import PyQt5
from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget, QMainWindow, QAction, qApp
from PyQt5.QtGui import QIcon
HEIGHT = 800
WIDTH = 1300
class Menu():
def __init__(self):
QMainWindow().__init__()
self.menubar = QMainWindow().menuBar()
self.file = self.menubar.addMenu('&File')
self.exitAction = QAction(QIcon('exit.png'), '&Exit', self)
self.exitAction.setShortcut('Ctrl+Q')
self.exitAction.setStatusTip('Exit application')
self.exitAction.triggered.connect(self.close)
self.file.addAction(self.exitAction)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
q = QDesktopWidget().availableGeometry()
r_w, r_h = q.width(), q.height()
self.setGeometry(r_w/2-WIDTH/2, r_h/2-HEIGHT/2, WIDTH, HEIGHT)
self.setFixedSize(1300, 800)
self.setWindowTitle('Lings')
self.setWindowIcon(QIcon('Lings.ico'))
menu = Menu()
self.show()
# class Window1(QMainWindow):
# def __init__(self):
# super().__init__()
# def initUI(self):
# mainWindow.menu()
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWindow = MainWindow()
sys.exit(app.exec_())