【Python】【PyQt】ComboBox

http://blog.sina.com.cn/s/blog_9b78c9110101d9ka.html

设定值:
_________________________________________________
大段文本
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)  

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值