Qt Designer Ui设计 功能增加

效果展示

输入密码,密码错误,弹出提示

密码正确,弹出提示并且关闭原窗口

代码(只提供重要关键主代码)lxh_log.py代码:

python 复制代码
import sys

from PySide6.QtWidgets import QApplication, QWidget, QPushButton

from pass_t import Ui_Form_T
from pass_f import Ui_Form_F
from lxh import Ui_Form
from PySide6.QtCore import Qt


class MyWidget(Ui_Form, QWidget):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.btn_log.clicked.connect(btn_log_slot)


class pass_f(Ui_Form_F, QWidget):
    def __init__(self):
        super().__init__()
        self.setupUi(self)


class pass_t(Ui_Form_T, QWidget):
    def __init__(self):
        super().__init__()
        self.setupUi(self)


def btn_log_slot():
    name = myWidget.line_name.text()
    password = myWidget.line_pas.text()
    if name == 'admin' and password == '123456':
        myWidget.close()
        pass_f.show()
    else:
        pass_t.show()
        myWidget.line_name.clear()
        myWidget.line_pas.clear()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    myWidget = MyWidget()
    pass_f = pass_f()
    pass_t = pass_t()
    myWidget.setWindowFlag(Qt.WindowType.FramelessWindowHint)

    myWidget.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
    pass_f.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
    pass_t.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
    myWidget.show()
    sys.exit(app.exec())

lxh文件夹存放图片文件信息

相关推荐
用户805533698033 天前
不止三件套:QObject 属性系统全关键字与运行时反射!
c++·qt
xcyxiner3 天前
DicomViewer (vcpkg Windows和ubuntu编译)7
qt
Quz8 天前
QML Hello World 入门示例
qt
xcyxiner11 天前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner11 天前
DicomViewer (后台线程处理文件)4
qt
xcyxiner12 天前
DicomViewer (添加模型类)3
qt
xcyxiner12 天前
DicomViewer (目录调整) 2
qt
xcyxiner13 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
LDR00614 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术14 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript