本文实例为大家分享了pyqt5利用pyqtDesigner实现登录界面的具体代码,供大家参考,具体内容如下
为便于操作 界面和逻辑分离
逻辑类:
import sys
import pymysql
from loginUI import * //导入
from PyQt5.QtWidgets import *
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtCore import *
from PyQt5.QtGui import
class Login(QtWidgets.QDialog):
def __init__(self):
super(Login, self).__init__()
self.ui = Ui_login_Ui()
self.ui.setupUi(self)
# self.setMinimumSize(QtCore.QSize(400, 200)) # 控制缩放范围
# self.setMaximumSize(QtCore.QSize(400, 200))
self.setWindowTitle("欢迎使用停车场管理系统")
self.setFixedSize(self.width(), self.height())
self.ui.labelTip.hide()
self.ui.labelTip.setText("密码或用户名不能为空!")
# 设置label字体
labelFont = QFont()
labelFont.setPixelSize(15)
# 设置动态背景
self.gif = QMovie('bg2.gif')
self.ui.label_2.setMovie(self.gif)
self.gif.start()
# 这在label属性
self.ui.labelTip.setStyleSheet(
"QLabel{color:red;font-size:12px;font-weight:bold;font-family:Roman times;}"
)
self.ui.userLabel.setStyleSheet("QLabel{background:white;}"
"QLabel{color:rgb(100,100,100,250);font-size:15px;font-weight:bold;font-family:Roman times;}"
"QLabel:hover{color:rgb(300,300,300,120);}")
self.ui.pwdlabel.setStyleSheet("QLabel{background:white;}"
"QLabel{color:rgb(100,100,100,250);font-size:15px;font-weight:bold;font-family:Roman times;}"
"QLabel:hover{color:rgb(300,300,300,120);}")
self.ui.label.setStyleSheet("QLabel{background:white;}"
"QLabel{color:rgb(100,100,100,250);font-size:15px;font-weight:bold;font-family:Roman times;}"
"QLabel:hover{color:rgb(300,300,300,120);}")
self.ui.loginButton.setStyleSheet("QPushButton{color:black}"
"QPushButton:hover{color:red}"
"QPushButton{background-color:lightblue}"
"QPushButton{border:2px}"
"QPushButton{border-radius:10px}"
"QPushButton{padding:2px 4px}")
self.ui.registerButton.setStyleSheet("QPushButton{color:black}"
"QPushButton:hover{color:red}"
&