您的位置:首页 > 编程语言 > Qt开发

pyqt 取值

2015-08-01 15:48 411 查看
设定值:

_________________________________________________

大段文本

self.textEdit.setPlainText(text)

静态label

self.lbl.setText("PyQt4")

设定静态label初始值

self.lbl.setText("hello"+self.singlelineEdit.text())

字体

self.label.setFont(font)

修改颜色

self.label.setStyleSheet("QWidget { background-color: %s }" % color.name())

获取值:

_________________________________________________

单行输入框

self.singlelineEdit.text()

单选radiobox,单选按钮本来就没有value的

self.radiobutton.isCheck()

滑动取值spinbox

self.spinbox.value()

获得日期值

thedate=self.calendarWidget.selectedDate()

日期值转化为string

thedatestring=str(thedate.toPyDate())

下拉列表combobox值的初始化

def __init__(self, parent = None):

self.typelist=['first', 'second', 'third']

self.addcommobox()

def addcommobox(self):

for i in self.typelist:

self.typecomboBox.addItem(i)

下拉列表combobox值

self.typecomboBox.currentText()

下拉列表combobox的index

self.typecomboBox.currentIndex()

其他功能:

____________

打开文件:

def on_openfile_clicked(self):

dlg = PyQt4.QtGui.QFileDialog(self)

self.filename = dlg.getOpenFileName()

from os.path import isfile

if isfile(self.filename):

import codecs

text = codecs.open(self.filename,'r','cp936').read()

self.textEdit.setPlainText(text)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: