本文整理汇总了Python中PyQt5.QtWidgets.QProgressBar.setMaximumSize方法的典型用法代码示例。如果您正苦于以下问题:Python QProgressBar.setMaximumSize方法的具体用法?Python QProgressBar.setMaximumSize怎么用?Python QProgressBar.setMaximumSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QProgressBar
的用法示例。
在下文中一共展示了QProgressBar.setMaximumSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ShipHp
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setMaximumSize [as 别名]
class ShipHp(QWidget):
def __init__(self, parent):
super(ShipHp, self).__init__(parent)
self.vbox = QVBoxLayout()
self.vbox.setSpacing(0)
self.vbox.setContentsMargins(0,3,0,3)
self.setLayout(self.vbox)
self.hp = QLabel(self)
#self.hp.setMinimumSize(QSize(0, 50))
self.vbox.addWidget(self.hp)
self.hp_bar = QProgressBar(self)
self.vbox.addWidget(self.hp_bar)
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.hp_bar.setSizePolicy(sizePolicy)
self.hp_bar.setMinimumSize(QSize(100, 10))
self.hp_bar.setMaximumSize(QSize(100, 10))
self.vbox.addItem(QSpacerItem(40, 20,
QSizePolicy.Minimum,
QSizePolicy.Expanding))
def set_hp(self, hp, maxhp):
self.hp.setText(HP_FORMAT.format(hp, maxhp))
self.hp_bar.setValue(hp*100/maxhp)
self.hp_bar.setFormat('')
rate = float(hp) / float(maxhp)
if rate <= 0.25:
self.setProperty('damage', 'serious')
elif rate <= 0.50:
self.setProperty('damage', 'middle')
elif rate <= 0.75:
self.setProperty('damage', 'slight')
else:
self.setProperty('damage', 'none')
self.style().unpolish(self.hp_bar)
self.style().polish(self.hp_bar)
self.update()
# for apply stylesheet
def paintEvent(self, pe):
opt = QStyleOption()
opt.initFrom(self)
p = QPainter(self)
s = self.style()
s.drawPrimitive(QStyle.PE_Widget, opt, p, self)
示例2: FuelBulletMeter
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setMaximumSize [as 别名]
class FuelBulletMeter(QWidget):
def __init__(self, parent):
super(FuelBulletMeter, self).__init__(parent)
self.vbox = QVBoxLayout()
self.vbox.setSpacing(0)
self.vbox.setContentsMargins(0,3,0,3)
self.setLayout(self.vbox)
self.fuel_bar = QProgressBar(self)
self.vbox.addWidget(self.fuel_bar)
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.fuel_bar.setSizePolicy(sizePolicy)
self.fuel_bar.setMinimumSize(QSize(80, 10))
self.fuel_bar.setMaximumSize(QSize(80, 10))
self.bullet_bar = QProgressBar(self)
self.vbox.addWidget(self.bullet_bar)
self.bullet_bar.setSizePolicy(sizePolicy)
self.bullet_bar.setMinimumSize(QSize(80, 10))
self.bullet_bar.setMaximumSize(QSize(80, 10))
def _set_bar(self, widget, rate, state):
widget.setValue(int(rate*100))
widget.setFormat('')
widget.setProperty('amount', state)
self.style().unpolish(widget)
self.style().polish(widget)
def set_val(self, ship):
self._set_bar(self.fuel_bar, ship.fuel_rate(), ship.fuel_state())
self._set_bar(self.bullet_bar, ship.bull_rate(), ship.bull_state())
# for apply stylesheet
def paintEvent(self, pe):
opt = QStyleOption()
opt.initFrom(self)
p = QPainter(self)
s = self.style()
s.drawPrimitive(QStyle.PE_Widget, opt, p, self)
示例3: SearchWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setMaximumSize [as 别名]
#.........这里部分代码省略.........
"""
replaceFileAll(replText)
**Signal** emitted, when 'Replace All' had been pressed
""" # pylint: disable=W0105
def __init__(self, plugin):
QFrame.__init__(self, core.workspace())
self._mode = None
self.plugin = plugin
uic.loadUi(os.path.join(os.path.dirname(__file__), 'SearchWidget.ui'), self)
self.cbSearch.setCompleter(None)
self.cbReplace.setCompleter(None)
self.cbMask.setCompleter(None)
self.fsModel = QDirModel(self.cbPath.lineEdit())
self.fsModel.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
self.cbPath.lineEdit().setCompleter(QCompleter(self.fsModel,
self.cbPath.lineEdit()))
self._pathBackspaceShortcut = QShortcut(QKeySequence("Ctrl+Backspace"), self.cbPath, self._onPathBackspace)
self._pathBackspaceShortcut.setContext(Qt.WidgetWithChildrenShortcut)
# TODO QDirModel is deprecated but QCompleter does not yet handle
# QFileSystemodel - please update when possible."""
self.cbSearch.setCompleter(None)
self.pbSearchStop.setVisible(False)
self.pbReplaceCheckedStop.setVisible(False)
self._progress = QProgressBar(self)
self._progress.setAlignment(Qt.AlignCenter)
self._progress.setToolTip(self.tr("Search in progress..."))
self._progress.setMaximumSize(QSize(80, 16))
core.mainWindow().statusBar().insertPermanentWidget(1, self._progress)
self._progress.setVisible(False)
# cd up action
self.tbCdUp = QToolButton(self.cbPath.lineEdit())
self.tbCdUp.setIcon(QIcon(":/enkiicons/go-up.png"))
self.tbCdUp.setCursor(Qt.ArrowCursor)
self.tbCdUp.installEventFilter(self) # for drawing button
self.cbSearch.installEventFilter(self) # for catching Tab and Shift+Tab
self.cbReplace.installEventFilter(self) # for catching Tab and Shift+Tab
self.cbPath.installEventFilter(self) # for catching Tab and Shift+Tab
self.cbMask.installEventFilter(self) # for catching Tab and Shift+Tab
self._closeShortcut = QShortcut(QKeySequence("Esc"), self)
self._closeShortcut.setContext(Qt.WidgetWithChildrenShortcut)
self._closeShortcut.activated.connect(self.hide)
# connections
self.cbSearch.lineEdit().textChanged.connect(self._onSearchRegExpChanged)
self.cbSearch.lineEdit().returnPressed.connect(self._onReturnPressed)
self.cbReplace.lineEdit().returnPressed.connect(self._onReturnPressed)
self.cbPath.lineEdit().returnPressed.connect(self._onReturnPressed)
self.cbMask.lineEdit().returnPressed.connect(self._onReturnPressed)
self.cbRegularExpression.stateChanged.connect(self._onSearchRegExpChanged)
self.cbCaseSensitive.stateChanged.connect(self._onSearchRegExpChanged)
self.cbWholeWord.stateChanged.connect(self._onSearchRegExpChanged)
self.tbCdUp.clicked.connect(self._onCdUpPressed)