当前位置: 首页>>代码示例>>Python>>正文


Python QProgressBar.setMaximumWidth方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QProgressBar.setMaximumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QProgressBar.setMaximumWidth方法的具体用法?Python QProgressBar.setMaximumWidth怎么用?Python QProgressBar.setMaximumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QProgressBar的用法示例。


在下文中一共展示了QProgressBar.setMaximumWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PowerIndicator

# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setMaximumWidth [as 别名]
class PowerIndicator():
    parent = None
    progressbar = None
    text = None

    maxVoltPerCell = 0
    minVoltPerCell = 0

    fullStyle = "QProgressBar::chunk { background-color: #00EE00; }"
    halfStyle = "QProgressBar::chunk { background-color: #FFCC00; }"
    emptyStyle = "QProgressBar::chunk { background-color: #FF5050; }"

    def __init__(self, parent, minVoltPerCell = 3.2, maxVoltPerCell = 4.2):
        self.minVoltPerCell = 3.2
        self.maxVoltPerCell = 4.2

        self.parent = parent
        self.text = QLabel('', parent)

        self.progressbar = QProgressBar(parent)
        self.progressbar.setMaximumWidth(100)
        self.progressbar.setMaximumHeight(10)
        self.progressbar.setMaximum(100)
        self.progressbar.setMinimum(0)
        self.progressbar.setTextVisible(False)

        parent.statusBar.addPermanentWidget(self.progressbar)
        parent.statusBar.addPermanentWidget(self.text)

    def updateProgressBar(self, voltage):
        pct = ((voltage - self.minVoltPerCell) / (self.maxVoltPerCell-self.minVoltPerCell))*100
        self.progressbar.setValue(pct)

        if pct <= 20:
            self.progressbar.setStyleSheet(self.emptyStyle)
        elif pct <= 50:
            self.progressbar.setStyleSheet(self.halfStyle)
        else:
            self.progressbar.setStyleSheet(self.fullStyle)

    def newMessage(self, message, data):
        if message == 'POW':
            data = data.split()

            if len(data) < 2:
                return

            volts = unpack('!f', bytes.fromhex(data[0]))[0]
            amps = unpack('!f', bytes.fromhex(data[1]))[0]

            self.text.setText("%.2f V/cell, %.3f A" % (volts/4, amps))
            self.updateProgressBar(volts/4)
开发者ID:strnk,项目名称:skippycopter,代码行数:54,代码来源:power.py

示例2: QuadStatusBar

# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setMaximumWidth [as 别名]
class QuadStatusBar(QHBoxLayout):
    positionChanged = pyqtSignal(int, int, int)  # x,y,z

    def __init__(self, parent=None):
        QHBoxLayout.__init__(self, parent)
        self.setContentsMargins(0, 4, 0, 0)
        self.setSpacing(0)
        self.timeControlFontSize = 12

    def showXYCoordinates(self):
        self.zLabel.setHidden(True)
        self.zSpinBox.setHidden(True)

    def showXYZCoordinates(self):
        self.zLabel.setHidden(False)
        self.zSpinBox.setHidden(False)

    def hideTimeSlider(self, flag):
        visibleBefore = not self.timeSlider.isHidden()
        self.timeSlider.setHidden(flag)
        self.timeEndButton.setHidden(flag)
        self.timeStartButton.setHidden(flag)
        self.timePreviousButton.setHidden(flag)
        self.timeNextButton.setHidden(flag)
        self._registerTimeframeShortcuts(enabled=not flag, remove=visibleBefore)

    def setToolTipTimeButtons(self, croppingFlag=False):
        self.timeStartButton.setToolTip("First Frame")
        self.timeEndButton.setToolTip("Last Frame")
        self.timePreviousButton.setToolTip("Previous Frame")
        self.timeNextButton.setToolTip("Next Frame")

    def setToolTipTimeSlider(self, croppingFlag=False):
        self.timeSlider.setToolTip("Choose the time coordinate of the current dataset.")

    def createQuadViewStatusBar(
        self, xbackgroundColor, xforegroundColor, ybackgroundColor, yforegroundColor, zbackgroundColor, zforegroundColor
    ):
        self.xLabel, self.xSpinBox = _get_pos_widget("X", xbackgroundColor, xforegroundColor)
        self.yLabel, self.ySpinBox = _get_pos_widget("Y", ybackgroundColor, yforegroundColor)
        self.zLabel, self.zSpinBox = _get_pos_widget("Z", zbackgroundColor, zforegroundColor)

        self.xSpinBox.delayedValueChanged.connect(partial(self._handlePositionBoxValueChanged, "x"))
        self.ySpinBox.delayedValueChanged.connect(partial(self._handlePositionBoxValueChanged, "y"))
        self.zSpinBox.delayedValueChanged.connect(partial(self._handlePositionBoxValueChanged, "z"))

        self.addWidget(self.xLabel)
        self.addWidget(self.xSpinBox)
        self.addWidget(self.yLabel)
        self.addWidget(self.ySpinBox)
        self.addWidget(self.zLabel)
        self.addWidget(self.zSpinBox)

        self.addSpacing(10)

        self.crosshairsCheckbox = QCheckBox()
        self.crosshairsCheckbox.setChecked(False)
        self.crosshairsCheckbox.setCheckable(True)
        self.crosshairsCheckbox.setText("Crosshairs")
        self.addWidget(self.crosshairsCheckbox)

        self.addSpacing(10)

        self.busyIndicator = QProgressBar()
        self.busyIndicator.setMaximumWidth(200)
        self.busyIndicator.setMaximum(0)
        self.busyIndicator.setMinimum(0)
        self.busyIndicator.setVisible(False)
        self.busyIndicator.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.addWidget(self.busyIndicator)
        self.setStretchFactor(self.busyIndicator, 1)

        self.addStretch()

        self.addSpacing(20)

        self.timeSpinBox = DelayedSpinBox(750)

        icons_dir = os.path.dirname(volumina.__file__) + "/icons"

        self.timeStartButton = QToolButton()
        self.timeStartButton.setIcon(QIcon(icons_dir + "/skip-start.png"))
        self.addWidget(self.timeStartButton)
        self.timeStartButton.clicked.connect(self._onTimeStartButtonClicked)
        # self.timeStartButton.setFixedWidth(4*self.timeControlFontSize)

        self.timePreviousButton = QToolButton()
        self.timePreviousButton.setIcon(QIcon(icons_dir + "/play-reverse.png"))
        self.addWidget(self.timePreviousButton)
        self.timePreviousButton.clicked.connect(self._onTimePreviousButtonClicked)
        # self.timePreviousButton.setFixedWidth(4*self.timeControlFontSize)

        self.timeSlider = QSlider(Qt.Horizontal)
        self.timeSlider.setMinimumWidth(10)
        self.timeSlider.setMaximumWidth(200)
        self.setToolTipTimeSlider()
        self.addWidget(self.timeSlider)
        self.timeSlider.valueChanged.connect(self._onTimeSliderChanged)

        self.timeNextButton = QToolButton()
#.........这里部分代码省略.........
开发者ID:ilastik,项目名称:volumina,代码行数:103,代码来源:sliceSelectorHud.py


注:本文中的PyQt5.QtWidgets.QProgressBar.setMaximumWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。