如果登录成功,我已尝试连接主窗口并一起登录。我导入了主窗口类。我不完全确定这是如何工作的,但我得到一个错误。我怎么能解决这个问题?
from MainWindow import Ui_MainMenu
...
def get_value_from_user(self):
Correct_details = False
while Correct_details==False:
inputusername=self.UsernameEdit.text()
inputpassword=self.PasswordEdit.text()
cur.execute("SELECT password FROM tblStaff WHERE username='"+inputusername+"'")
password=str(cur.fetchone())
password=password[2:-3]
cur.execute("SELECT firstname FROM tblStaff WHERE username='"+inputusername+"'")
FirstName=str(cur.fetchone())
FirstName=FirstName[2:-3]
cur.execute("SELECT surname FROM tblStaff WHERE username='"+inputusername+"'")
Surname=str(cur.fetchone())
Surname=Surname[2:-3]
if str(password) == str(inputpassword):
self.msgBox1 = QMessageBox(QMessageBox.Information,'Successful', "Succesfully Logged in")
self.msgBox1.show()
Correct_details = True
else:
self.msgBox2 = QMessageBox(QMessageBox.Information, 'Warning',
"The Username or Password you have entered is incorrect - Please try again (CASE SENSITIVE)")
self.msgBox2.show()
self.UsernameEdit.clear()
self.PasswordEdit.clear()
break
self.msgBox1 = QMessageBox(QMessageBox.Information,
'Successful', "Succesfully Logged in")
self.msgBox1.show()
MainMenu= Ui_MainMenu(self)
MainMenu.exec()
Login.close()
def retranslateUi(self, Login):
Login.setWindowTitle(_translate("Login", "Login", None))
self.UsernameEdit.setPlaceholderText(_translate("Login", "Username", None))
self.PasswordEdit.setPlaceholderText(_translate("Login", "Password", None))
self.ExitButton.setText(_translate("Login", "Exit", None))
self.LoginButton.setText(_translate("Login", "Login", None))
self.LoginTitle.setText(_translate("Login", "Login", None))
self.label.setText(_translate("Login", "<html><head/><body><p align=\"center\"><span style=\" font-size:10pt; font-weight:600;\">STATION</span></p><p align=\"center\"><span style=\" font-size:10pt; font-weight:600;\">JEWELLERS </span></p></body></html>", None))
class Ui_MainMenu (object):
def __init__ (self, parent = None):
super (Ui_MainMenu, self).__init__ ()
self.ui = Ui_MainMenu ()
self.ui.setupUi(self)
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Login = QtGui.QDialog()
ui = Ui_Login()
ui.setupUi(Login)
Login.show()
sys.exit(app.exec_())