у меня были разные вариации:
for row in logs:
if row == login:
for row in passs:
if row == passw:
self.exampleApp.show()
break
elif row != passw:
self.errorapp.show()
break
elif row != login:
self.errorapp.show()
break
for row in logs:
if row == login:
for row in passs:
if row == passw:
self.exampleApp.show()
break
else:
self.errorapp.show()
break
else:
self.errorapp.show()
break
else:
self.errorapp.show()
break
for row in logs:
if row == login:
for row in passs:
if row == passw:
try:
self.exampleApp.show()
except:
self.errorapp.show()
Ума не приложу что не так, но если я попадаю и в логин и в пароль то у меня выводится сразу 2 окна - и которое нужно и диалоговое окно с ошибкой. Подскажите пожалуйста, ниже код всего окна
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QInputDialog, QLineEdit, QDialog
import pymysql.cursors
from main1open import Windowone
from main2open import Windowtwo
from ruinedopen import Windowthree
import mysql.connector
from mysql.connector import MySQLConnection, Error
connection = pymysql.connect(host='127.0.0.1',
user='root',
password='adminadmin',
db='mydb',
charset='utf8mb4',)
print("connected!!!")
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(400, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(130, 360, 131, 41))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(130, 410, 131, 41))
self.pushButton_2.setObjectName("pushButton_2")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(50, 179, 281, 31))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_2.setGeometry(QtCore.QRect(50, 260, 281, 31))
self.lineEdit_2.setObjectName("lineEdit_2")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(50, 230, 111, 31))
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(True)
font.setItalic(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(50, 150, 91, 31))
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(True)
font.setItalic(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "log in"))
self.pushButton_2.setText(_translate("MainWindow", "create an account"))
self.label.setText(_translate("MainWindow", "password"))
self.label_2.setText(_translate("MainWindow", "Login"))
class ExampleApp(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.onClicked)
self.pushButton_2.clicked.connect(self.onClicked1)
self.exampleApp = Windowone()
self.errorapp = Windowthree()
self.exampleApp_2 = Windowtwo()
def onClicked(self):
with connection:
curs = connection.cursor()
curs.execute("SELECT username FROM клиент")
logs = curs.fetchall()# выполнение запроса
login = (self.lineEdit.text(),)
curs.execute("SELECT password FROM клиент WHERE username = %s ", login[0])
passs = curs.fetchall()
passw = (self.lineEdit_2.text(), )
for row in logs:
if row == login:
for row in passs:
if row == passw:
try:
self.exampleApp.show()
except:
self.errorapp.show()
def onClicked1(self):
self.exampleApp_2.show()
class errorapp(QDialog,ExampleApp):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.onClicked)
self.errorapp = Windowthree()
if __name__=="__main__":
app = QtWidgets.QApplication(sys.argv)
window = ExampleApp()
window.show()
sys.exit(app.exec_())