# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'D:\Desktop\login.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import time
from PyQt5.QtWidgets import QMessageBox
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
from PyQt5.QtWidgets import QApplication
import pymysql
import main
class Login(QtWidgets.QMainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.setupUi(self)
self.retranslateUi(self)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 295)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
self.tabWidget.setGeometry(QtCore.QRect(0, 0, 791, 271))
self.tabWidget.setObjectName("tabWidget")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.label_username = QtWidgets.QLabel(self.tab)
self.label_username.setGeometry(QtCore.QRect(10, 40, 51, 16))
self.label_username.setObjectName("label_username")
self.label_password = QtWidgets.QLabel(self.tab)
self.label_password.setGeometry(QtCore.QRect(10, 80, 61, 16))
self.label_password.setObjectName("label_password")
self.label_phone = QtWidgets.QLabel(self.tab)
self.label_phone.setGeometry(QtCore.QRect(10, 120, 51, 16))
self.label_phone.setObjectName("label_phone")
self.label_Email = QtWidgets.QLabel(self.tab)
self.label_Email.setGeometry(QtCore.QRect(10, 150, 31, 16))
self.label_Email.setObjectName("label_Email")
self.label_root_password = QtWidgets.QLabel(self.tab)
self.label_root_password.setGeometry(QtCore.QRect(10, 210, 61, 21))
self.label_root_password.setObjectName("label_root_password")
self.lineEdit_username = QtWidgets.QLineEdit(self.tab)
self.lineEdit_username.setGeometry(QtCore.QRect(150, 40, 113, 21))
self.lineEdit_username.setObjectName("lineEdit_username")
self.label_W_Q = QtWidgets.QLabel(self.tab)
self.label_W_Q.setGeometry(QtCore.QRect(10, 180, 81, 16))
self.label_W_Q.setObjectName("label_W_Q")
self.lineEdit_password = QtWidgets.QLineEdit(self.tab)
self.lineEdit_password.setGeometry(QtCore.QRect(150, 80, 113, 21))
self.lineEdit_password.setObjectName("lineEdit_password")
self.lineEdit_Email = QtWidgets.QLineEdit(self.tab)
self.lineEdit_Email.setGeometry(QtCore.QRect(150, 150, 113, 21))
self.lineEdit_Email.setObjectName("lineEdit_Email")
self.lineEdit_phone = QtWidgets.QLineEdit(self.tab)
self.lineEdit_phone.setGeometry(QtCore.QRect(150, 120, 113, 21))
self.lineEdit_phone.setObjectName("lineEdit_phone")
self.lineEdit_root_password = QtWidgets.QLineEdit(self.tab)
self.lineEdit_root_password.setGeometry(QtCore.QRect(150, 220, 113, 21))
self.lineEdit_root_password.setObjectName("lineEdit_root_password")
self.lineEdit_W_Q = QtWidgets.QLineEdit(self.tab)
self.lineEdit_W_Q.setGeometry(QtCore.QRect(150, 180, 113, 21))
self.lineEdit_W_Q.setObjectName("lineEdit_W_Q")
self.label_name = QtWidgets.QLabel(self.tab)
self.label_name.setGeometry(QtCore.QRect(300, 50, 31, 16))
self.label_name.setObjectName("label_name")
self.lineEdit_name = QtWidgets.QLineEdit(self.tab)
self.lineEdit_name.setGeometry(QtCore.QRect(350, 50, 113, 21))
self.lineEdit_name.setObjectName("lineEdit_name")
self.label_signature = QtWidgets.QLabel(self.tab)
self.label_signature.setGeometry(QtCore.QRect(300, 90, 72, 15))
self.label_signature.setObjectName("label_signature")
self.lineEdit_signature = QtWidgets.QLineEdit(self.tab)
self.lineEdit_signature.setGeometry(QtCore.QRect(300, 120, 341, 121))
self.lineEdit_signature.setObjectName("lineEdit_signature")
self.pushButton_register = QtWidgets.QPushButton(self.tab)
self.pushButton_register.setGeometry(QtCore.QRect(670, 100, 93, 28))
self.pushButton_register.setObjectName("pushButton_register")
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.label_user_name = QtWidgets.QLabel(self.tab_2)
self.label_user_name.setGeometry(QtCore.QRect(340, 20, 51, 16))
self.label_user_name.setObjectName("label_user_name")
self.lineEdit_9 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_9.setGeometry(QtCore.QRect(310, 60, 113, 21))
self.lineEdit_9.setObjectName("lineEdit_9")
self.label_password_2 = QtWidgets.QLabel(self.tab_2)
self.label_password_2.setGeometry(QtCore.QRect(350, 100, 31, 16))
self.label_password_2.setObjectName("label_password_2")
self.lineEdit_10 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_10.setGeometry(QtCore.QRect(310, 130, 113, 21))
self.lineEdit_10.setObjectName("lineEdit_10")
self.pushButton_login = QtWidgets.QPushButton(self.tab_2)
self.pushButton_login.setGeometry(QtCore.QRect(320, 190, 93, 28))
self.pushButton_login.setObjectName("pushButton_login")
self.tabWidget.addTab(self.tab_2, "")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label_username.setText(_translate("MainWindow", "用户名"))
self.label_password.setText(_translate("MainWindow", "用户密码"))
self.label_phone.setText(_translate("MainWindow", "手机号"))
self.label_Email.setText(_translate("MainWindow", "邮箱"))
self.label_root_password.setText(_translate("MainWindow", "管理密码"))
self.label_W_Q.setText(_translate("MainWindow", "weixin/QQ"))
self.label_name.setText(_translate("MainWindow", "昵称"))
self.label_signature.setText(_translate("MainWindow", "个性签名"))
self.pushButton_register.setText(_translate("MainWindow", "注册"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "注册"))
self.label_user_name.setText(_translate("MainWindow", "用户名"))
self.label_password_2.setText(_translate("MainWindow", "密码"))
self.pushButton_login.setText(_translate("MainWindow", "登录"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "登录"))
class register_progress(QtWidgets.QMainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.setupUi(self)
self.retranslateUi(self)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(748, 104)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
self.progressBar.setGeometry(QtCore.QRect(10, 25, 721, 23))
self.progressBar.setProperty("value", 24)
self.progressBar.setObjectName("progressBar")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(10, 70, 711, 20))
self.label.setObjectName("label")
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "正在进行的操作"))
def register_TF(username, password, Email, phone, root_password, W_Q):
# 用户名判断
username_code = True
password_code = True
Email_code = True
phone_code = True
root_password_code = True
W_Q_code = True
username_element_list = (
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W',
'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w',
'x', 'y', 'z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '_')
while username_code:
if len(username) > 20:
QMessageBox(QMessageBox.Critical, '用户名不合法', '用户名长度不能大于20个字符').exec_()
username_code = False
if len(username) == 0:
QMessageBox(QMessageBox.Critical, '用户名不合法', '用户名不能为空').exec_()
username_code = False
for i in username:
if i not in username_element_list:
QMessageBox(QMessageBox.Critical, '用户名不合法', '用户名只能包括大写字母、小写字母、数字、下划线_').exec_()
username_code = False
return username_code, password_code, Email_code, phone_code, root_password_code, W_Q_code
def register():
global ex
username = ex.lineEdit_username.text()
password = ex.lineEdit_password.text()
Email = ex.lineEdit_Email.text()
phone = ex.lineEdit_phone.text()
root_password = ex.lineEdit_root_password.text()
W_Q = ex.lineEdit_W_Q.text()
# print(username,password,Email,phone,root_password,W_Q)
username_code, password_code, Email_code, phone_code, root_password_code, W_Q_code = register_TF(username, password, Email, phone, root_password, W_Q)
if username_code and password_code and Email_code and phone_code and root_password_code and W_Q_code:
print('合法')
def login():
global ex
user_name = ex.lineEdit_9.text()
password = ex.lineEdit_10.text()
# print(user_name,password)
app = QApplication(sys.argv)
ex = Login()
ex.pushButton_register.clicked.connect(register)
ex.pushButton_login.clicked.connect(login)
ex.show()
sys.exit(app.exec_())
以上是一个很正常的登录注册半成品(原创,只做了用户名验证)但是当用户名通过验证的时候返回,然后就未响应了
有没有人可以找出原因并给出解决办法。