error with python qt message box -
The message box keeps 'flashing': s This is not a crash, but it just keeps on opening and reopening. How can I fix this problem?
self Translator (English) QtCore.QObject.connect (self.ExitButton, QtCore.SIGNAL (_fromUtf8 ( "clicked ()")), login.close) QtCore.QObject.connect (self.LoginButton, QtCore.SIGNAL ( "clicked () ", Self.get_value_from_user) QtCore.QMetaObject.connectSlotsByName (login) Login.setTabOrder (self.LoginButton, self.UsernameEdit) Login.setTabOrder (Self.UsernameEdit, self.PasswordEdit) Login.setTabOrder (self.PasswordEdit, self.ExitButton) def get_value_from_user (self): correct_details = right 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 first name = [2: -3] cur.execute (" SELECT surname FROM tblStaff WHERE User Name = '"+ Inp Name + " ') nickname = RR (Curkfetch (a)) nickname = nickname [2 -3] if str (password) == str (inputpassword): self.msgBox1 = QMessageBox (QMessageBox.Information, 'successful', "successfully connected was") self.msgBox1.show () Correct_details = True else: self.msgBox2 = QMessageBox (QMessageBox.Information, 'Warning', "you entered user name or password is incorrect" ) Self.msgbox2.show () Your program logic is incorrect get_value_from_user () inside the method, you have the line while correct_details == incorrect: . This is the line that is causing the problem. After the user has entered his wrong login details, he does not get the option to re-enter, you can be repeatedly using the self.usernameEdit and self.PasswordEdit and of course The loop continues to be correct, and therefore the loop continues forever and every loop is repeated, you pop up the message box that they are wrong. The Loop mentioned above needs to be elsewhere in your code (possibly in the form call get_value_from_user ), allowing the user to re-enter his username and password the get_value_from_user () method is probably variable should Correct_Details to return to the calling method to render it again come to that user login form or proceed carefully.
Comments
Post a Comment