效果展示
输入密码,密码错误,弹出提示
密码正确,弹出提示并且关闭原窗口
代码(只提供重要关键主代码)lxh_log.py代码:
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文件夹存放图片文件信息