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


Python QToolButton.setEnabled方法代码示例

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


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

示例1: SliderControl

# 需要导入模块: from PyQt4.Qt import QToolButton [as 别名]
# 或者: from PyQt4.Qt.QToolButton import setEnabled [as 别名]
    class SliderControl(QObject):
        """This class implements a slider control for a colormap"""

        def __init__(self, name, value, minval, maxval, step, format="%s: %.1f"):
            QObject.__init__(self)
            self.name, self.value, self.minval, self.maxval, self.step, self.format = \
                name, value, minval, maxval, step, format
            self._default = value
            self._wlabel = None

        def makeControlWidgets(self, parent, gridlayout, row, column):
            toprow = QWidget(parent)
            gridlayout.addWidget(toprow, row * 2, column)
            top_lo = QHBoxLayout(toprow)
            top_lo.setContentsMargins(0, 0, 0, 0)
            self._wlabel = QLabel(self.format % (self.name, self.value), toprow)
            top_lo.addWidget(self._wlabel)
            self._wreset = QToolButton(toprow)
            self._wreset.setText("reset")
            self._wreset.setToolButtonStyle(Qt.ToolButtonTextOnly)
            self._wreset.setAutoRaise(True)
            self._wreset.setEnabled(self.value != self._default)
            QObject.connect(self._wreset, SIGNAL("clicked()"), self._resetValue)
            top_lo.addWidget(self._wreset)
            self._wslider = QwtSlider(parent)
            # This works around a stupid bug in QwtSliders -- see comments on histogram zoom wheel above
            self._wslider_timer = QTimer(parent)
            self._wslider_timer.setSingleShot(True)
            self._wslider_timer.setInterval(500)
            QObject.connect(self._wslider_timer, SIGNAL("timeout()"), self.setValue)
            gridlayout.addWidget(self._wslider, row * 2 + 1, column)
            self._wslider.setRange(self.minval, self.maxval)
            self._wslider.setStep(self.step)
            self._wslider.setValue(self.value)
            self._wslider.setTracking(False)
            QObject.connect(self._wslider, SIGNAL("valueChanged(double)"), self.setValue)
            QObject.connect(self._wslider, SIGNAL("sliderMoved(double)"), self._previewValue)

        def _resetValue(self):
            self._wslider.setValue(self._default)
            self.setValue(self._default)

        def setValue(self, value=None, notify=True):
            # only update widgets if already created
            self.value = value
            if self._wlabel is not None:
                if value is None:
                    self.value = value = self._wslider.value()
                self._wreset.setEnabled(value != self._default)
                self._wlabel.setText(self.format % (self.name, self.value))
                # stop timer if being called to finalize the change in value
                if notify:
                    self._wslider_timer.stop()
                    self.emit(SIGNAL("valueChanged"), self.value)

        def _previewValue(self, value):
            self.setValue(notify=False)
            self._wslider_timer.start(500)
            self.emit(SIGNAL("valueMoved"), self.value)
开发者ID:ska-sa,项目名称:tigger,代码行数:61,代码来源:Colormaps.py


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