PyQt progress bar
发布时间:2020-12-17 17:30:44 所属栏目:Python 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 #!/usr/bin/env python# --*--codig: utf8 --*--from PyQt4 import QtGuifrom PyQt4 import QtCoreclass BaseProgressBar(QtGui.QWidget): updateProg
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 #!/usr/bin/env python # --*--codig: utf8 --*-- from PyQt4 import QtGui from PyQt4 import QtCore class BaseProgressBar(QtGui.QWidget): updateProgress = QtCore.pyqtSignal(str) def __init__(self,text='',parent=None): super(BaseProgressBar,self).__init__(parent) self.setFixedHeight(50) self.text = text self.progressbar = QtGui.QProgressBar( ) self.progressbar.setTextVisible(True) self.updateProgress.connect(self.setValue) self.bottomBorder = QtGui.QWidget( ) self.bottomBorder.setStyleSheet(""" background: palette(shadow); """) self.bottomBorder.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,QtGui.QSizePolicy.Fixed)) self.bottomBorder.setMinimumHeight(1) self.label = QtGui.QLabel(self.text) self.label.setStyleSheet(""" font-weight: bold; """) self.layout = QtGui.QVBoxLayout( ) self.layout.setContentsMargins(10,10,0) self.layout.addWidget(self.label) self.layout.addWidget(self.progressbar) self.mainLayout = QtGui.QVBoxLayout( ) self.mainLayout.setContentsMargins(0,0) self.mainLayout.addLayout(self.layout) self.mainLayout.addWidget(self.bottomBorder) self.setLayout(self.mainLayout) self.totalValue = 0 def setValue(self,value): self.totalValue += len(value) self.progressbar.setValue(self.totalValue) def setMax(self,value): self.progressbar.setMaximum(value) 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |