学习日志020---qt信号与槽

发布于:2024-12-07 ⋅ 阅读:(136) ⋅ 点赞:(0)

作业

import sys


from PySide6.QtWidgets import QApplication, QWidget,QPushButton,QLineEdit

from Form import Ui_Form
from second import Ui_second
from PySide6.QtCore import Qt

class MyWidget(QWidget,Ui_Form):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.btn = self.findChild(QPushButton,"btn")
        self.username =   self.findChild(QLineEdit,"username")
        self.password = self.findChild(QLineEdit, "password")
        self.btn.clicked.connect(mynext)

def mynext():
    if myWidget.username.text() == "admin" and myWidget.password.text() == "123456":
        myWidget.close()
        second.show()
    else:
        myWidget.username.setText("")
        myWidget.password.setText("")


class Second(QWidget,Ui_second):
    def __init__(self):
        super().__init__()
        self.setupUi(self)

if __name__ == "__main__":
    app = QApplication(sys.argv)

    myWidget = MyWidget()
    myWidget.setWindowFlag(Qt.WindowType.FramelessWindowHint)

    myWidget.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)

    second = Second()
    second.setWindowFlag(Qt.WindowType.FramelessWindowHint)

    second.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
    myWidget.show()


    sys.exit(app.exec())

 

 


网站公告

今日签到

点亮在社区的每一天
去签到