文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>QInputDialog

QInputDialog

时间:2010-04-03  来源:digwtx

Qt输入对话框示例

#!/usr/bin/python
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore

class InputDialog(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.hbox=QtGui.QHBoxLayout(self)
        self.btn_1=QtGui.QPushButton('Text',self)
        self.btn_2=QtGui.QPushButton('passwd',self)
        self.lbl_1=QtGui.QLineEdit()
        self.hbox.addWidget(self.btn_1)
        self.hbox.addWidget(self.btn_2)
        self.hbox.addWidget(self.lbl_1)

        self.connect(self.btn_1, QtCore.SIGNAL('clicked()'), self.textDialog)
        self.connect(self.btn_2, QtCore.SIGNAL('clicked()'), self.pswdDialog)
    def textDialog(self):
        text, ok = QtGui.QInputDialog.getText(self, \
                                              'Input Dialog', 'Enter your name:')
        if ok:
            self.lbl_1.setText(unicode(text))
    def pswdDialog(self):
        pswd, ok = QtGui.QInputDialog.getText(self, \
                                              'Input Dialog', \
                                              'Enter your passwd:', \
                                              QtGui.QLineEdit.Password)
        if ok:
            self.lbl_1.setText(unicode(pswd))

app = QtGui.QApplication(sys.argv)
icon = InputDialog()
icon.show()
app.exec_()


相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载