博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PyQt5 下拉列表控件
阅读量:3898 次
发布时间:2019-05-23

本文共 1078 字,大约阅读时间需要 3 分钟。

#QComBoximport sysfrom PyQt5.QtWidgets import *from PyQt5.QtCore import *from PyQt5.QtGui import *class QComboxDemo(QWidget):    def __init__(self):        super(QComboxDemo,self).__init__()        self.initUI()    def initUI(self):        self.setWindowTitle('下拉列表控件')        self.resize(300,200)        layout= QVBoxLayout()        self.label =QLabel('请选择编辑语言')        self.cb = QComboBox()        self.cb.addItem('C++')        self.cb.addItem('Python')        self.cb.addItems(['Java',"C#",'Ruby'])        self.cb.currentIndexChanged.connect(self.selectChange)        layout.addWidget(self.label)        layout.addWidget(self.cb)        self.setLayout(layout)    def selectChange(self,i):        self.label.setText(self.cb.currentText())        self.label.adjustSize()        for count in range(self.cb.count()):            print('item'+str(count)+'='+self.cb.itemText(count))            print('current index', i, 'select changed'+ self.cb.currentText())if __name__ == '__main__':    app =QApplication(sys.argv)    main = QComboxDemo()    main.show()    app.exit(app.exec_())

在这里插入图片描述

转载地址:http://aoben.baihongyu.com/

你可能感兴趣的文章
5年开发经验的我被几条朋友圈打击到,点燃自己冲击阿里面经!
查看>>
5年工作经验的我放弃安逸,一份来自腾讯魔鬼面试的终极考验!
查看>>
学JAVA吗同学,这篇Sping boot 确定不了解下么?
查看>>
(3年+offer)华为技术岗面试初面+综合面试经验总结
查看>>
男默女泪,努力复习的我终于通过社招进入BAT工作了!(JAVA+JVM+框架+中间件+Spring干货分享)
查看>>
Python 导包
查看>>
dok_matrix
查看>>
theano 后端爆内存
查看>>
os.environ 和 keras.json
查看>>
后台面试经典问题-手写LRU算法
查看>>
Part-Guided Attention Learning for Vehicle Instance Retrieval
查看>>
Deep Residual Learning for Image Recognition
查看>>
Bag of Tricks and A Strong Baseline for Deep Person Re-identification
查看>>
vue+flask实现视频目标检测yolov5
查看>>
关于BigInteger
查看>>
UIScrollView不能响应UITouch事件
查看>>
iOS TextFiled 文本密码切换 光标偏移解决
查看>>
iOS 当前应用所占内存和设备可用内存
查看>>
iOS 文件属性
查看>>
UIView的layoutSubviews和drawRect方法何时调用
查看>>