登录和注册界面

登 录 和 注 册 界 面 登录和注册界面


界面之间的交互,只通过函数接口,避免紧耦合


MVC架构:
View:ui和panel中只实现视图
V:main中处理,实现controller
M:model中存储数据模板


设置背景图片

QWidget#Form{
	border-image: url(:/register/images/white_bg.png);
}

设置字体颜色和大小

color:rgb(240,240,240)
font:16pt "方正舒体"

设置背景消除

background-color:transparent;
color:rgb(240,240,240)

设置选中状态变色

QPushButton {
   
	background-color: rgb(119, 74, 255);
}

QPushButton:hover {
	
	background-color: rgb(255, 183, 101);
}

QPushButton:pressed {
	background-color: rgb(255, 169, 188);
}

设置无边框

border:none;

设置底边框

border-bottom:1px solid;

边框由方变圆(设置圆角)为宽和高的一半

QPushButton {
   border-radius:25px; 
}

设置可被选中状态

QPushButton {
   border-radius:25px; 
	background-color: rgb(55, 58, 255);
}

QPushButton:hover {
   border:4px double rgb(255, 216, 20);
}

QPushButton:checked {
  
	background-color: rgb(255, 248, 38);
}

在这里插入图片描述

设置下拉框可修改

在这里插入图片描述

一 注册(Register)

images_rc.py

# -*- coding: utf-8 -*-

# Resource object code
#
# Created by: The Resource Compiler for PyQt5 (Qt v5.15.2)
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore

qt_resource_data = b"\
\x00\x00\x00\xe4\
\x00\
\x00\x0f\x77\x78\x9c\xeb\x0c\xf0\x73\xe7\xe5\x92\xe2\x62\x60\x60\
\xe0\xf5\xf4\x70\x09\x62\x60\x60\xe2\x65\x60\x60\x9c\xc8\xc1\x04\
\x14\xc9\x34\x13\x4f\x63\x60\xe0\xb7\xf3\x74\x71\x0c\xa9\x60\x7c\
\x7b\xd5\x90\xf1\xb0\x81\x00\x8b\xa3\xba\xcb\x11\xf9\x69\x13\x2d\
\xa6\x16\x1f\x0d\x92\x08\x5d\xae\xbf\xfc\xe6\xf9\xcf\x36\xd3\xdd\
\x1b\x18\x18\x99\x58\xe2\x1a\x7f\xef\x3b\x6f\xf9\xfe\xfd\xaf\x7f\
\xd3\x1d\xc1\x02\x5a\x0b\x84\x4d\x0b\x15\x1d\x1a\x18\x1a\x39\x5f\
\x1c\xd1\xd1\x61\x62\xe1\x10\x58\xd1\xe0\x77\xe5\x48\x2b\x48\x52\
\x6d\x81\xf0\xe6\x0d\x1c\x02\x0a\x0e\x0b\x98\xac\x02\x85\xc5\x41\
\x92\x33\x1a\xfc\xce\x1c\x52\x02\xa9\xe7\x7a\xe1\xe2\x1b\x03\x92\
\x4c\x60\xb2\x32\xe4\xee\x1e\x35\x6c\xd4\xb0\x51\xc3\x46\x0d\x1b\
\x35\x6c\xd4\xb0\x51\xc3\x46\x0d\x1b\x35\x6c\xd4\xb0\x51\xc3\x46\
\x0d\x1b\x35\x6c\xd4\xb0\x41\x6d\x98\x7d\xa3\x13\xa7\xbc\x89\x9d\
\xfb\x74\x60\x87\x9a\xc1\xd3\xd5\xcf\x65\x9d\x53\x42\x13\x00\xe5\
\xb2\x38\x16\
"

qt_resource_name = b"\
\x00\x08\
\x0b\xe0\xa5\xc2\
\x00\x72\
\x00\x65\x00\x67\x00\x69\x00\x73\x00\x74\x00\x65\x00\x72\
\x00\x06\
\x07\x03\x7d\xc3\
\x00\x69\
\x00\x6d\x00\x61\x00\x67\x00\x65\x00\x73\
\x00\x0c\
\x0a\x38\x42\x27\
\x00\x77\
\x00\x68\x00\x69\x00\x74\x00\x65\x00\x5f\x00\x62\x00\x67\x00\x2e\x00\x70\x00\x6e\x00\x67\
"

qt_resource_struct_v1 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x16\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
\x00\x00\x00\x28\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\
"

qt_resource_struct_v2 = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x16\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x28\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x79\x2c\x5f\xfb\x23\
"

qt_version = [int(v) for v in QtCore.qVersion().split('.')]
if qt_version < [5, 8, 0]:
    rcc_version = 1
    qt_resource_struct = qt_resource_struct_v1
else:
    rcc_version = 2
    qt_resource_struct = qt_resource_struct_v2

def qInitResources():
    QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)

def qCleanupResources():
    QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)

qInitResources()

register.py

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'register.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# 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.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(500, 450)
        Form.setMinimumSize(QtCore.QSize(500, 450))
        Form.setMaximumSize(QtCore.QSize(500, 450))
        Form.setStyleSheet("QWidget#Form{\n"
"    border-image: url(:/register/images/white_bg.png);\n"
"}")
        self.main_menu_btn = QtWidgets.QPushButton(Form)
        self.main_menu_btn.setGeometry(QtCore.QRect(40, 20, 51, 51))
        self.main_menu_btn.setStyleSheet("QPushButton {\n"
"   border-radius:25px; \n"
"    background-color: rgb(55, 58, 255);\n"
"}\n"
"\n"
"QPushButton:hover {\n"
"   border:4px double rgb(255, 216, 20);\n"
"}\n"
"\n"
"QPushButton:checked {\n"
"  \n"
"    background-color: rgb(255, 248, 38);\n"
"}\n"
"\n"
"\n"
"")
        self.main_menu_btn.setCheckable(True)
        self.main_menu_btn.setObjectName("main_menu_btn")
        self.about_menu_btn = QtWidgets.QPushButton(Form)
        self.about_menu_btn.setGeometry(QtCore.QRect(120, 20, 51, 51))
        self.about_menu_btn.setStyleSheet("QPushButton {\n"
"   border-radius:25px; \n"
"    background-color: rgb(55, 58, 255);\n"
"}\n"
"\n"
"QPushButton:hover {\n"
"   border:4px double rgb(255, 216, 20);\n"
"}\n"
"\n"
"QPushButton:checked {\n"
"  \n"
"    background-color: rgb(255, 248, 38);\n"
"}\n"
"\n"
"\n"
"")
        self.about_menu_btn.setCheckable(False)
        self.about_menu_btn.setObjectName("about_menu_btn")
        self.reset_menu_btn = QtWidgets.QPushButton(Form)
        self.reset_menu_btn.setGeometry(QtCore.QRect(120, 90, 51, 51))
        self.reset_menu_btn.setStyleSheet("QPushButton {\n"
"   border-radius:25px; \n"
"    background-color: rgb(55, 58, 255);\n"
"}\n"
"\n"
"QPushButton:hover {\n"
"   border:4px double rgb(255, 216, 20);\n"
"}\n"
"\n"
"QPushButton:checked {\n"
"  \n"
"    background-color: rgb(255, 248, 38);\n"
"}\n"
"\n"
"\n"
"")
        self.reset_menu_btn.setCheckable(False)
        self.reset_menu_btn.setObjectName("reset_menu_btn")
        self.exit_menu_btn = QtWidgets.QPushButton(Form)
        self.exit_menu_btn.setGeometry(QtCore.QRect(40, 90, 51, 51))
        self.exit_menu_btn.setStyleSheet("QPushButton {\n"
"   border-radius:25px; \n"
"    background-color: rgb(55, 58, 255);\n"
"}\n"
"\n"
"QPushButton:hover {\n"
"   border:4px double rgb(255, 216, 20);\n"
"}\n"
"\n"
"QPushButton:checked {\n"
"  \n"
"    background-color: rgb(255, 248, 38);\n"
"}\n"
"\n"
"\n"
"")
        self.exit_menu_btn.setCheckable(False)
        self.exit_menu_btn.setObjectName("exit_menu_btn")
        self.layoutWidget = QtWidgets.QWidget(Form)
        self.layoutWidget.setGeometry(QtCore.QRect(190, 180, 271, 197))
        self.layoutWidget.setObjectName("layoutWidget")
        self.formLayout = QtWidgets.QFormLayout(self.layoutWidget)
        self.formLayout.setContentsMargins(0, 0, 0, 0)
        self.formLayout.setVerticalSpacing(20)
        self.formLayout.setObjectName("formLayout")
        self.label = QtWidgets.QLabel(self.layoutWidget)
        self.label.setObjectName("label")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)
        self.account_le = QtWidgets.QLineEdit(self.layoutWidget)
        self.account_le.setMinimumSize(QtCore.QSize(0, 30))
        self.account_le.setStyleSheet("border:none;\n"
"border-bottom:1px solid;\n"
"")
        self.account_le.setClearButtonEnabled(True)
        self.account_le.setObjectName("account_le")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.account_le)
        self.label_2 = QtWidgets.QLabel(self.layoutWidget)
        self.label_2.setObjectName("label_2")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)
        self.password_le = QtWidgets.QLineEdit(self.layoutWidget)
        self.password_le.setMinimumSize(QtCore.QSize(0, 30))
        self.password_le.setStyleSheet("border:none;\n"
"border-bottom:1px solid;\n"
"")
        self.password_le.setClearButtonEnabled(True)
        self.password_le.setObjectName("password_le")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.password_le)
        self.label_3 = QtWidgets.QLabel(self.layoutWidget)
        self.label_3.setObjectName("label_3")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_3)
        self.confirm_pwd_le = QtWidgets.QLineEdit(self.layoutWidget)
        self.confirm_pwd_le.setMinimumSize(QtCore.QSize(0, 30))
        self.confirm_pwd_le.setStyleSheet("border:none;\n"
"border-bottom:1px solid;\n"
"")
        self.confirm_pwd_le.setClearButtonEnabled(True)
        self.confirm_pwd_le.setObjectName("confirm_pwd_le")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.confirm_pwd_le)
        self.register_btn = QtWidgets.QPushButton(self.layoutWidget)
        self.register_btn.setEnabled(False)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.register_btn.sizePolicy().hasHeightForWidth())
        self.register_btn.setSizePolicy(sizePolicy)
        self.register_btn.setMinimumSize(QtCore.QSize(0, 45))
        self.register_btn.setStyleSheet("QPushButton {\n"
"   \n"
"    background-color: rgb(90, 98, 255);\n"
"}\n"
"\n"
"QPushButton:hover {\n"
"    \n"
"    background-color: rgb(11, 3, 255);\n"
"}\n"
"\n"
"QPushButton:pressed {\n"
"    \n"
"    background-color: rgb(164, 161, 255);\n"
"}\n"
"\n"
"QPushButton:disabled {\n"
"    \n"
"    background-color:rgb(111, 111, 111);\n"
"}")
        self.register_btn.setObjectName("register_btn")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.register_btn)
        self.about_menu_btn.raise_()
        self.reset_menu_btn.raise_()
        self.exit_menu_btn.raise_()
        self.layoutWidget.raise_()
        self.main_menu_btn.raise_()

        self.retranslateUi(Form)
        self.main_menu_btn.clicked.connect(Form.show_hide_menu)
        self.about_menu_btn.clicked.connect(Form.about_medicine_system)
        self.reset_menu_btn.clicked.connect(Form.reset)
        self.exit_menu_btn.clicked.connect(Form.exit)
        self.register_btn.clicked.connect(Form.check_register)
        self.main_menu_btn.clicked['bool'].connect(self.main_menu_btn.showMenu)
        self.account_le.textChanged['QString'].connect(Form.enable_register_btn)
        self.password_le.textChanged['QString'].connect(Form.enable_register_btn)
        self.confirm_pwd_le.textChanged['QString'].connect(Form.enable_register_btn)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.main_menu_btn.setText(_translate("Form", "菜单"))
        self.about_menu_btn.setText(_translate("Form", "关于"))
        self.reset_menu_btn.setText(_translate("Form", "重置"))
        self.exit_menu_btn.setText(_translate("Form", "退出"))
        self.label.setText(_translate("Form", "账    号:"))
        self.label_2.setText(_translate("Form", "密    码:"))
        self.label_3.setText(_translate("Form", "确认密码:"))
        self.register_btn.setText(_translate("Form", "注册"))
import images_rc


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    sys.exit(app.exec_())

Register_Pane.py

# 0.导入需要的包和模块
from PyQt5.Qt import *
import sys
from resources.register import Ui_Form

class ReisterPane(QWidget,Ui_Form):

    exit_signal = pyqtSignal()
    register_account_pwd_signal = pyqtSignal(str,str)

    def __init__(self,parent=None,*args,**kwargs):
        super().__init__(parent,*args,**kwargs)
        self.setAttribute(Qt.WA_StyledBackground,True)
        self.setupUi(self)
        self.animation_targets = [self.about_menu_btn,self.reset_menu_btn,self.exit_menu_btn]
        self.animation_targets_pos = [target.pos() for target in  self.animation_targets]

    def show_hide_menu(self,checked):
        animation_group = QSequentialAnimationGroup(self)
        for idx,target in enumerate(self.animation_targets):
            animation = QPropertyAnimation()
            animation.setTargetObject(target)
            animation.setPropertyName(b"pos")
            if not checked:
                animation.setStartValue(self.main_menu_btn.pos())
                animation.setEndValue(self.animation_targets_pos[idx])
            else:
                animation.setEndValue(self.main_menu_btn.pos())
                animation.setStartValue(self.animation_targets_pos[idx])
            animation.setDuration(200)
            animation_group.addAnimation(animation)
        animation_group.start(QAbstractAnimation.DeleteWhenStopped)

    def about_medicine_system(self):
        print("about_medicine_system")

    def reset(self):
        self.account_le.clear()
        self.password_le.clear()
        self.confirm_pwd_le.clear()

    def exit(self):
        self.exit_signal.emit()

    def check_register(self):
        account_txt = self.account_le.text()
        password_txt = self.password_le.text()
        self.register_account_pwd_signal.emit(account_txt,password_txt)

    def enable_register_btn(self):
        account_txt = self.account_le.text()
        password_txt = self.password_le.text()
        cp_txt = self.confirm_pwd_le.text()
        if len(account_txt) > 0 and len(password_txt) > 0 and len(cp_txt) > 0 and password_txt == cp_txt:
            self.register_btn.setEnabled(True)
        else:
            self.register_btn.setEnabled(False)




if __name__ == '__main__':

    # 1.创建一个应用程序对象
    app = QApplication(sys.argv)
    # 2.控件的操作
    # 2.1创建控件
    window = ReisterPane()
    # 2.2设置控件
    window.exit_signal.connect(lambda :print("退出"))
    window.register_account_pwd_signal.connect(lambda a,p:print(a,p))

    # 2.3展示控件
    window.show()
    # 3.应用程序的执行,进入到信息循环
    sys.exit(app.exec_())

二 登录(Login)

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'login.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# 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.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(500, 450)
        Form.setMinimumSize(QtCore.QSize(500, 450))
        Form.setMaximumSize(QtCore.QSize(500, 450))
        self.verticalLayout = QtWidgets.QVBoxLayout(Form)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.widget = QtWidgets.QWidget(Form)
        self.widget.setStyleSheet("")
        self.widget.setObjectName("widget")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget)
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_2.setSpacing(0)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.login_top_bg_label = QtWidgets.QLabel(self.widget)
        self.login_top_bg_label.setStyleSheet("background-color: rgb(109, 99, 255);")
        self.login_top_bg_label.setText("")
        self.login_top_bg_label.setObjectName("login_top_bg_label")
        self.horizontalLayout_2.addWidget(self.login_top_bg_label)
        self.verticalLayout.addWidget(self.widget)
        self.login_bottom = QtWidgets.QWidget(Form)
        self.login_bottom.setStyleSheet("")
        self.login_bottom.setObjectName("login_bottom")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.login_bottom)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 15)
        self.horizontalLayout.setSpacing(0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.pushButton = QtWidgets.QPushButton(self.login_bottom)
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout.addWidget(self.pushButton, 0, QtCore.Qt.AlignBottom)
        self.widget_3 = QtWidgets.QWidget(self.login_bottom)
        self.widget_3.setStyleSheet("")
        self.widget_3.setObjectName("widget_3")
        self.gridLayout = QtWidgets.QGridLayout(self.widget_3)
        self.gridLayout.setObjectName("gridLayout")
        self.pushButton_3 = QtWidgets.QPushButton(self.widget_3)
        self.pushButton_3.setMinimumSize(QtCore.QSize(0, 35))
        self.pushButton_3.setObjectName("pushButton_3")
        self.gridLayout.addWidget(self.pushButton_3, 3, 0, 1, 2)
        self.auto_login_cb = QtWidgets.QCheckBox(self.widget_3)
        self.auto_login_cb.setObjectName("auto_login_cb")
        self.gridLayout.addWidget(self.auto_login_cb, 2, 0, 1, 1)
        self.remember_pwd_cb = QtWidgets.QCheckBox(self.widget_3)
        self.remember_pwd_cb.setObjectName("remember_pwd_cb")
        self.gridLayout.addWidget(self.remember_pwd_cb, 2, 1, 1, 1, QtCore.Qt.AlignRight)
        self.account_cb = QtWidgets.QComboBox(self.widget_3)
        self.account_cb.setMinimumSize(QtCore.QSize(0, 30))
        self.account_cb.setMaximumSize(QtCore.QSize(16777215, 30))
        self.account_cb.setEditable(True)
        self.account_cb.setObjectName("account_cb")
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/login/images/test.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.account_cb.addItem(icon, "")
        self.account_cb.addItem("")
        self.gridLayout.addWidget(self.account_cb, 0, 0, 1, 2)
        self.pwd_le = QtWidgets.QLineEdit(self.widget_3)
        self.pwd_le.setMinimumSize(QtCore.QSize(0, 30))
        self.pwd_le.setObjectName("pwd_le")
        self.gridLayout.addWidget(self.pwd_le, 1, 0, 1, 2)
        self.horizontalLayout.addWidget(self.widget_3)
        self.pushButton_2 = QtWidgets.QPushButton(self.login_bottom)
        self.pushButton_2.setMinimumSize(QtCore.QSize(80, 80))
        self.pushButton_2.setObjectName("pushButton_2")
        self.horizontalLayout.addWidget(self.pushButton_2, 0, QtCore.Qt.AlignBottom)
        self.horizontalLayout.setStretch(0, 2)
        self.horizontalLayout.setStretch(1, 6)
        self.horizontalLayout.setStretch(2, 2)
        self.verticalLayout.addWidget(self.login_bottom)
        self.verticalLayout.setStretch(0, 2)
        self.verticalLayout.setStretch(1, 3)

        self.retranslateUi(Form)
        self.pushButton.clicked.connect(Form.show_register_pane)
        self.pushButton_2.clicked.connect(Form.open_related_link)
        self.pushButton_3.clicked.connect(Form.check_login)
        self.auto_login_cb.clicked['bool'].connect(Form.auto_login)
        self.remember_pwd_cb.clicked['bool'].connect(Form.remember_pwd)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "注册账号"))
        self.pushButton_3.setText(_translate("Form", "安全登录"))
        self.auto_login_cb.setText(_translate("Form", "自动登录"))
        self.remember_pwd_cb.setText(_translate("Form", "记住密码"))
        self.account_cb.setItemText(0, _translate("Form", "1171657161"))
        self.account_cb.setItemText(1, _translate("Form", "224006099"))
        self.pushButton_2.setText(_translate("Form", "二维码"))
import images_rc


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    sys.exit(app.exec_())

Login_Pane.py

# 0.导入需要的包和模块
from PyQt5.Qt import *
import sys
from resources.login import Ui_Form
class LoginPane(QWidget,Ui_Form):

    show_register_pane_signal = pyqtSignal()
    check_login_signal = pyqtSignal(str,str)

    def __init__(self,parent=None,*args,**kwargs):
        super().__init__(parent,*args,**kwargs)
        self.setAttribute(Qt.WA_StyledBackground,True)
        self.setupUi(self)
        movie = QMovie(":/login/images/login_bg.gif")
        self.login_top_bg_label.setScaledContents(True)
        self.login_top_bg_label.setMovie(movie)
        movie.start()

    def show_register_pane(self):
        self.show_register_pane_signal.emit()

    def open_related_link(self):
        link = "https://blog.csdn.net/qq_41375318/article/details/115941545"
        QDesktopServices.openUrl(QUrl(link))

    def check_login(self):
        account = self.account_cb.currentText()
        pwd = self.pwd_le.text()
        self.check_login_signal.emit(account,pwd)

    def auto_login(self,checked):
        print("自动登录",checked)
        if checked:
            self.remember_pwd_cb.setChecked(True)

    def remember_pwd(self,checked):
        print("记住密码",checked)
        if not checked:
            self.auto_login_cb.setChecked(False)

    def show_error_animation(self):
        animation = QPropertyAnimation(self)
        animation.setTargetObject(self.login_bottom)
        animation.setPropertyName(b"pos")
        animation.setKeyValueAt(0,self.login_bottom.pos())
        animation.setKeyValueAt(0.2, self.login_bottom.pos()+QPoint(15,0))
        animation.setKeyValueAt(0.5, self.login_bottom.pos())
        animation.setKeyValueAt(0.7, self.login_bottom.pos()+QPoint(-15,0))
        animation.setKeyValueAt(1, self.login_bottom.pos())
        animation.setDuration(200)
        animation.setLoopCount(3)
        animation.start(QAbstractAnimation.DeleteWhenStopped)


if __name__ == '__main__':

    # 1.创建一个应用程序对象
    app = QApplication(sys.argv)
    # 2.控件的操作
    # 2.1创建控件
    window = LoginPane()
    # 2.2设置控件



    # 2.3展示控件
    window.show()
    # 3.应用程序的执行,进入到信息循环
    sys.exit(app.exec_())

三 主界面(Main)

from PyQt5.Qt import *
import sys
from Login_Pane import LoginPane
from Register_Pane import ReisterPane
from Main_Window_Pane import MyMainWindow
if __name__ == '__main__':

    # 1.创建一个应用程序对象
    app = QApplication(sys.argv)
    # 控制面板的创建
    login_pane = LoginPane()
    register_pane = ReisterPane(login_pane)
    register_pane.move(0, login_pane.height())
    register_pane.show()
    main_pane = MyMainWindow()

    # 槽函数
    def exit_register_pane():
        animation = QPropertyAnimation(register_pane)
        animation.setTargetObject(register_pane)
        animation.setPropertyName(b"pos")
        animation.setStartValue(QPoint(0, 0))
        animation.setEndValue(QPoint(login_pane.width(),0))
        animation.setDuration(500)
        animation.start(QAbstractAnimation.DeleteWhenStopped)


    def show_register_pane():
        animation = QPropertyAnimation(register_pane)
        animation.setTargetObject(register_pane)
        animation.setPropertyName(b"pos")
        animation.setStartValue(register_pane.pos())
        animation.setEndValue(QPoint(0, 0))
        animation.setDuration(500)
        animation.start(QAbstractAnimation.DeleteWhenStopped)

    # 账号密码判定
    def check_login(account,password):
        if account == "1171657161" and password == "123456":
            print("登录成功")
            main_pane.show()
            login_pane.hide()

        else:
            login_pane.show_error_animation()

    # 信号连接
    register_pane.exit_signal.connect(exit_register_pane)
    register_pane.register_account_pwd_signal.connect(lambda a,p:print(a,p))
    login_pane.show_register_pane_signal.connect(show_register_pane)
    login_pane.check_login_signal.connect(check_login)


    # 展示控件
    login_pane.show()
    # 3.应用程序的执行,进入到信息循环
    sys.exit(app.exec_())
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值