Ошибка наследования
Почему ошибка? Класс AddWords.
Ошибка:
TypeError: Cannot create a consistent method resolution order (MRO) for bases QMainWindow, MainWindow
import PyQt5
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget, QMainWindow, QAction, qApp
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QTimer
import sqlite3
import random
HEIGHT = 750
WIDTH = 1300
class Menu(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.menubar = parent.menuBar()
self.file = self.menubar.addMenu('&Опции')
self.exitAction = QAction(QIcon('icons/cross-exit.ico'), '&Exit', self)
self.exitAction.setShortcut('Ctrl+Q')
self.exitAction.setStatusTip('Exit application')
self.exitAction.triggered.connect(parent.close)
self.file.addAction(self.exitAction)
def addMenu(self, text, command, icon, shortcut=None, statusTip=None) :
actionName = QAction(QIcon(icon), text, self)
if shortcut:
actionName.setShortcut(shortcut)
if statusTip:
actionName.setStatusTip(statusTip)
actionName.triggered.connect(command)
self.file.insertAction(self.exitAction, actionName)
def addNestedMenu(self, text, text2, text3, command, command2, icon, icon2):
words = self.file.addMenu(text)
action = QAction(QIcon(icon), text2, self)
action2 = QAction(QIcon(icon2), text3, self)
action.triggered.connect(command)
action2.triggered.connect(command2)
words.addAction(action)
words.addAction(action2)
self.file.addAction(self.exitAction)
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
def stylingsCss(self):
self.label.setStyleSheet("""
QLabel{
background-color: #E0FFFF;
border-radius: 25px;
}
""")
self.labelAnswer.setStyleSheet("""
QLabel{
background-color: #E0FFFF;
border-radius: 25px;
}
""")
self.labelEdit.setStyleSheet("background-color: #7FFFD4; border: none; border-radius: 25px;")
self.countLabel.setStyleSheet("""
QLabel{
font-size: 15px;
border-radius: 25px;
min-height: 50px;
max-height: 50px;
min-width: 50px;
max-width: 50px;
background-color: #FAF0E6;
border: 1px double #ADD8E6;
}
QToolTip {
background-color: #ffffff;
border: 1px solid green;
}
""")
self.courseButton.setStyleSheet("""
font-size: 15px;
border-radius: 15px;
min-height: 40px;
max-height: 40px;
min-width: 100px;
max-width: 50px;
background-color: #ADD8E6;
border: 1px double #90EE90;
""")
self.wordButton.setStyleSheet("""
QPushButton {
font-size: 15px;
border-radius: 15px;
min-height: 40px;
max-height: 40px;
min-width: 100px;
max-width: 50px;
background-color: #ADD8E6;
border: 1px double #90EE90;
}
QPushButton:hover:pressed {
background-color: green;
}
QPushButton:hover:!pressed {
background-color: yellow;
}
QToolTip {
background-color: #ffffff;
border: 1px solid green;
}
""")
def answerCheckerRus(self):
self.labelAnswer.setStyleSheet("""
background-color: #E0FFFF;
""")
self.labelAnswer.setText("")
self.labelEdit.setText("")
self.countLabel.setStyleSheet("""
QLabel{
font-size: 15px;
border-radius: 25px;
min-height: 50px;
max-height: 50px;
min-width: 50px;
max-width: 50px;
background-color: #FAF0E6;
border: 1px double #ADD8E6;
}
QToolTip {
background-color: #ffffff;
border: 1px solid green;
}
""")
if self.toggle == 1:
sqlLiteConnect(self, 'db/Lings_Words_Db.db', 'generalWords', 'Word', 'rus')
def answerCheckerEng(self):
self.labelAnswer.setStyleSheet("""
background-color: #E0FFFF;
""")
self.labelAnswer.setText("")
self.labelEdit.setText("")
self.countLabel.setStyleSheet("""
QLabel{
font-size: 15px;
border-radius: 25px;
min-height: 50px;
max-height: 50px;
min-width: 50px;
max-width: 50px;
background-color: #FAF0E6;
border: 1px double #ADD8E6;
}
QToolTip {
background-color: #ffffff;
border: 1px solid green;
}
""")
if self.toggle == 1:
sqlLiteConnect(self, 'db/Lings_Words_Db.db', 'generalWords', 'Word', 'eng')
def binderAnswerCheckerRus(self): # Связывание фуйкции answerCheckerRus через 1.5сек
QTimer.singleShot(1500, lambda: answerCheckerRus(self))
def binderAnswerCheckerEng(self): # Связывание фуйкции answerCheckerEng через 1.5сек
QTimer.singleShot(1500, lambda: answerCheckerEng(self))
def sqlLiteConnect(self, db, table, column_name, lang='eng'): #Подключение к БД + запись слов в лейбл
self.lang = lang
self.connect = sqlite3.connect(db)
self.cursor = self.connect.cursor()
self.query_columns = f"PRAGMA table_info('{table}')"
self.cursor.execute(self.query_columns)
self.queryRow = f"""SELECT id, Word, Translation FROM {table} WHERE id=?"""
self.cursor.execute(self.queryRow, (random.randint(0, 2000),))
self.text_db = self.cursor.fetchone()
if lang == 'eng':
self.label.setText(self.text_db[1].title())
else:
self.label.setText(self.text_db[2].title())
def checker(self): # Проверка на язык + выполнение функции answerChecker через 1500 мс
self.text_in_LabelEdit = self.labelEdit.text()
if self.lang == 'eng':
if self.text_in_LabelEdit == self.text_db[2]:
self.toggle = 1
self.labelAnswer.setStyleSheet('background-color: #90ff77; border-radius: 25px;')
self.labelAnswer.setText("Верно")
binderAnswerCheckerEng(self)
xCounter(self)
else:
self.toggle = 0
self.labelAnswer.setStyleSheet('background-color: #ff4040; border-radius: 25px;')
self.labelAnswer.setText(self.text_db[2])
binderAnswerCheckerEng(self)
self.var = 0
self.countLabel.setText("0")
self.countLabel.setStyleSheet("""
QLabel{
font: 20px Arial, bold;
border-radius: 25px;
min-height: 50px;
max-height: 50px;
min-width: 50px;
max-width: 50px;
background-color: #ff4040;
border: 1px solid black;
}
QToolTip {
background-color: #ffffff;
border: 1px solid green;
}
""")
else:
if self.text_in_LabelEdit == self.text_db[1]:
self.toggle = 1
self.labelAnswer.setStyleSheet('background-color: #90ff77; border-radius: 25px;')
self.labelAnswer.setText("Верно")
binderAnswerCheckerRus(self)
xCounter(self)
else:
self.toggle = 0
self.labelAnswer.setStyleSheet('background-color: #ff4040; border-radius: 25px;')
self.labelAnswer.setText(self.text_db[1])
binderAnswerCheckerRus(self)
self.var = 0
self.countLabel.setText("0")
def wordButtonToggler(self): #Переключение между языками
self.text_in_wordButton = self.wordButton.text()
self.labelEdit.setFocus()
if self.text_in_wordButton == 'EN':
self.wordButton.setText("RU")
sqlLiteConnect(self, 'db/Lings_Words_Db.db', 'generalWords', 'Word', 'rus')
else:
self.wordButton.setText("EN")
sqlLiteConnect(self, 'db/Lings_Words_Db.db', 'generalWords', 'Word', 'eng')
def xCounter(self):
self.var += 1
self.countLabel.setText(str(self.var))
self.countLabel.setStyleSheet("""
QLabel{
font: 20px Arial, bold;
border-radius: 25px;
min-height: 50px;
max-height: 50px;
min-width: 50px;
max-width: 50px;
background-color: #90ff77;
border: 1px solid black;
}
QToolTip {
background-color: #ffffff;
border: 1px solid green;
}
""")
self.var = 0
self.q = QDesktopWidget().availableGeometry()
self.r_w, self.r_h = self.q.width(), self.q.height()
self.setGeometry(self.r_w/2-WIDTH/2, self.r_h/2-HEIGHT/2, WIDTH, HEIGHT)
self.w = self.size().width()
self.h = self.size().height()
self.setFixedSize(1300, 750)
self.setWindowTitle('Lings')
self.setWindowIcon(QIcon('icons/Lings.ico'))
self.label = QtWidgets.QLabel("sdsd", self)
self.labelAnswer = QtWidgets.QLabel(self)
self.labelEdit = QtWidgets.QLineEdit(self)
self.countLabel = QtWidgets.QLabel('0', self)
self.courseButton = QtWidgets.QPushButton('Общий курс', self)
self.wordButton = QtWidgets.QPushButton('EN', self)
self.l_w, self.l_h = 500, 100
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.countLabel.setAlignment(QtCore.Qt.AlignCenter)
self.labelAnswer.setAlignment(QtCore.Qt.AlignCenter)
self.labelEdit.setAlignment(QtCore.Qt.AlignCenter)
self.labelAnswer.resize(self.l_w, self.l_h)
self.countLabel.resize(50, 50)
self.courseButton.resize(100, 40)
self.wordButton.resize(100, 40)
self.labelEdit.resize(self.l_w, self.l_h)
self.labelAnswer.move(self.w/2-self.l_w/2, 250)
self.countLabel.move(self.w/2-self.l_w/2+550, 275)
self.courseButton.move(self.w/2-self.l_w/2+750, 25)
self.wordButton.move(self.w/2-self.l_w/2-350, 25)
self.labelEdit.move(self.w/2-self.l_w/2, 400)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.resize(self.l_w, self.l_h)
self.label.move(self.w/2-self.l_w/2, 100)
self.label.setFont(QtGui.QFont('Verdana', 24))
self.labelAnswer.setFont(QtGui.QFont('Verdana', 24))
self.labelEdit.setFont(QtGui.QFont('Verdana', 24))
self.countLabel.setToolTip("Ваша серия правильных ответов")
self.wordButton.setToolTip("Изменение языка")
self.labelEdit.setFocus()
self.labelEdit.returnPressed.connect(lambda: checker(self))
self.wordButton.pressed.connect(lambda: wordButtonToggler(self))
self.menu = Menu(self)
self.menu.addNestedMenu('Свои слова', 'Добавить слова', 'Посмотреть список слов', lambda: AddWords(self), lambda: AddWords(self), 'icons/add.png', 'icons/test.ico')
stylingsCss(self)
sqlLiteConnect(self, 'db/Lings_Words_Db.db', 'generalWords', 'Word', 'eng')
self.show()
class AddWords(QMainWindow, MainWindow):
def __init__(self, parent=None):
super().__init__(parent, QtCore.Qt.Window)
self.initUI()
parent.hide()
def initUI(self):
self.q = QDesktopWidget().availableGeometry()
self.r_w, self.r_h = self.q.width(), self.q.height()
self.w = self.size().width()
self.h = self.size().height()
self.l_w, self.l_h = 500, 100
self.setGeometry(self.r_w/2-WIDTH/2, self.r_h/2-HEIGHT/2, WIDTH, HEIGHT)
self.setFixedSize(800, 400)
self.setWindowTitle('Lings2')
self.setWindowIcon(QIcon('icons/Lings.ico'))
self.lineEditAdd = QtWidgets.QLineEdit(self)
self.lineEditAdd.setAlignment(QtCore.Qt.AlignCenter)
self.lineEditAdd.resize(self.l_w, self.l_h)
self.lineEditAdd.setFont(QtGui.QFont('Verdana', 24))
self.lineEditAdd.move(self.w/2-self.l_w/2, 400)
self.menu = Menu(self)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
mainWindow = MainWindow()
sys.exit(app.exec_())```