日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

pyQt 每日一练习 -- 登录框

發布時間:2023/11/27 生活经验 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 pyQt 每日一练习 -- 登录框 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#coding=utf-8#第一個練習,登錄框import sys
from PyQt4 import QtGui,QtCore#登錄框
class LoginBox(QtGui.QWidget):def __init__(self):super(LoginBox, self).__init__()self.initUI()def initUI(self):vBoxLayout = QtGui.QVBoxLayout()hBoxLayout_1 = QtGui.QHBoxLayout()nameLabel = QtGui.QLabel(u"姓名:", self)self.nameInputEdit = QtGui.QLineEdit(self)self.nameInputEdit.textChanged.connect(self.inputName)hBoxLayout_1.addWidget(nameLabel)hBoxLayout_1.addWidget(self.nameInputEdit)vBoxLayout.addLayout(hBoxLayout_1)hBoxLayout_2 = QtGui.QHBoxLayout()passwordLabel = QtGui.QLabel(u"密碼:", self)self.passwordInputEdit = QtGui.QLineEdit(self)self.passwordInputEdit.textChanged.connect(self.inputPassword)hBoxLayout_2.addWidget(passwordLabel)hBoxLayout_2.addWidget(self.passwordInputEdit)vBoxLayout.addLayout(hBoxLayout_2)hBoxLayout_3 = QtGui.QHBoxLayout()okBtn = QtGui.QPushButton(u"確定", self)cancleBtn = QtGui.QPushButton(u"取消", self)okBtn.clicked.connect(self.clickOkBtn)cancleBtn.clicked.connect(self.clickCancleBtn)hBoxLayout_3.addWidget(okBtn)hBoxLayout_3.addWidget(cancleBtn)vBoxLayout.addLayout(hBoxLayout_3)self.setLayout(vBoxLayout)self.setWindowIcon(QtGui.QIcon("icon.png"))self.setWindowTitle(u"登錄框")self.resize(300, 150)self.setCenterPos()def inputName(self, text):self.name = textprint "input name is " + str(self.name)def inputPassword(self, text):self.password = textprint "input password " + str(self.password)def clickOkBtn(self):sender = self.sender()print unicode(sender.text()) + " be clicked"info = u"姓名:" + str(self.name) + u" 密碼:" + str(self.password)reply = QtGui.QMessageBox.question(self, u"提示", info, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)if reply == QtGui.QMessageBox.Yes:print "right!"else:self.nameInputEdit.setText("")self.passwordInputEdit.setText("")def clickCancleBtn(self):sender = self.sender()print unicode(sender.text()) + " be clicked"self.close()def setCenterPos(self):screen = QtGui.QDesktopWidget().screenGeometry()selfSize = self.size()self.move((screen.width() - selfSize.width())/2, (screen.height() - selfSize.height())/2)def main():app = QtGui.QApplication(sys.argv)lb = LoginBox()lb.show()sys.exit(app.exec_())if __name__ == "__main__":main()

轉載于:https://www.cnblogs.com/shiweihappy/p/4246425.html

總結

以上是生活随笔為你收集整理的pyQt 每日一练习 -- 登录框的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。