黑松山资源网 Design By www.paidiu.com
本文实例为大家分享了pyqt5登录界面的实现模板,供大家参考,具体内容如下
说明
本例,展示了通过登录界面打开主界面的实现方式。
其中,登录的账号与密码判断都比较简单,请大家根据自己需要,自行完善补充。
【如下代码,完全复制,直接运行,即可使用】
import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtGui import * ################################################ #######创建主窗口 ################################################ class MainWindow(QMainWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setWindowTitle('主界面') self.showMaximized() ################################################ #######对话框 ################################################ 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.pushButton_quit = QPushButton() self.pushButton_quit.setText("取消") self.verticalLayout.addWidget(self.pushButton_quit) ###### 绑定按钮事件 self.pushButton_enter.clicked.connect(self.on_pushButton_enter_clicked) self.pushButton_quit.clicked.connect(QCoreApplication.instance().quit) def on_pushButton_enter_clicked(self): # 账号判断 if self.lineEdit_account.text() == "": return # 密码判断 if self.lineEdit_password.text() == "": return # 通过验证,关闭对话框并返回1 self.accept() ################################################ #######程序入门 ################################################ if __name__ == "__main__": app = QApplication(sys.argv) dialog = logindialog() if dialog.exec_()==QDialog.Accepted: the_window = MainWindow() the_window.show() sys.exit(app.exec_())
本文如有帮助,敬请留言鼓励。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年10月07日
2024年10月07日
- 班得瑞原装进口《第五张新世纪专辑:迷雾森林+EP》1CD[APE/CUE分轨][334.2MB]
- 田震.1997-顺其自然(日版)【红星生产社】【WAV+CUE】
- 小虫.1996-想得太美【滚石】【WAV+CUE】
- 谢采妘.2016-邓丽君名曲专辑【丰荣】【WAV+CUE】
- 张含韵.2007-一人一梦【天中文化】【WAV+CUE】
- 蟑螂乐队.1999-帮个忙【福茂】【WAV+CUE】
- 张宇.2001-替身【EMI百代】【WAV+CUE】
- 班得瑞原装进口《第六张新世纪专辑:日光海岸》1CD[APE/CUE分轨][339.5MB]
- 班得瑞原装进口《第七张新世纪专辑:梦花园》1CD[APE/CUE分轨][331.4MB]
- 班得瑞原装进口《第八张新世纪专辑:琉璃湖畔》1CD[APE/CUE分轨][286.4MB]
- 魏如萱.2011-在哪里(EP)【添翼创越】【WAV+CUE】
- 群星.1981-新金曲奖·青年创作园地12合辑(喜玛拉雅复刻版)【歌林】【WAV+CUE】
- 麦洁文.1989-新曲与精丫新艺宝】【WAV+CUE】
- SNH48《薄荷糖 (Mint Candy)》[320K/MP3][33.72MB]
- SNH48《薄荷糖 (Mint Candy)》[FLAC/分轨][78.59MB]