zoukankan      html  css  js  c++  java
  • pyqt5界面切换

    #主要的思路就是创建两个frame(如果有两个以上同理)使用setVisible()函数显示或者隐藏frame 参数是bool值
    import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtGui import * class logindialog(QDialog): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle('登录界面') self.resize(200, 200) self.setFixedSize(self.width(), self.height()) self.setWindowFlags(Qt.WindowCloseButtonHint) self.frame = QFrame(self) self.verticalLayout = QVBoxLayout(self.frame) self.lineEdit_account = QLineEdit() self.lineEdit_account.setPlaceholderText("请输入账号") self.verticalLayout.addWidget(self.lineEdit_account) self.lineEdit_password = QLineEdit() self.lineEdit_password.setPlaceholderText("请输入密码") self.verticalLayout.addWidget(self.lineEdit_password) self.pushButton_enter = QPushButton() self.pushButton_enter.setText("进入下一个界面") self.verticalLayout.addWidget(self.pushButton_enter) self.frame1 = QFrame(self) self.verticalLayout = QVBoxLayout(self.frame1) self.pushButton_quit = QPushButton() self.pushButton_quit.setText("回到主页面") self.verticalLayout.addWidget(self.pushButton_quit) self.frame1.setVisible(False) self.pushButton_enter.clicked.connect(self.on_pushButton_enter_clicked) self.pushButton_quit.clicked.connect(self.on_pushButton_enter_clicked_1) def on_pushButton_enter_clicked(self): self.frame1.setVisible(True) self.frame.setVisible(False) def on_pushButton_enter_clicked_1(self): self.frame1.setVisible(False) self.frame.setVisible(True) if __name__ == "__main__": app = QApplication(sys.argv) dialog = logindialog() if dialog.exec_() == QDialog.Accepted: sys.exit(app.exec_())

      

  • 相关阅读:
    Tornado-Lesson06-ORM、SQLAlchemy连接数据库、Module和增删改查
    Tornado-Lesson04-模版、模版转义、静态文件的引用
    Tornado-Lesson05-模版继承、函数和类导入、ui_methods和ui_modules
    博弈论
    给图片添加水印
    Apsara Clouder专项技能认证:实现调用API接口
    好用的工具
    书写是为了更好的思考
    使用与破解ExcelVBA密码
    一款可以直接下载浏览器sources资源的Chrome插件
  • 原文地址:https://www.cnblogs.com/pythonClub/p/10307155.html
Copyright © 2011-2022 走看看