예제 #1
0
파일: widgets.py 프로젝트: shiva16/openalea
    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.start_spinbox = QtGui.QSpinBox()
        self.end_spinbox = QtGui.QSpinBox()

        # Fill background to avoid to see text or widget behind
        self.setAutoFillBackground(True)

        AbstractIntRangeWidget.__init__(self)

        self.start_spinbox.setMinimumHeight(18)
        self.end_spinbox.setMinimumHeight(18)

        self.start_spinbox.valueChanged.connect(self.end_spinbox.setMinimum)
        self.end_spinbox.valueChanged.connect(self.start_spinbox.setMaximum)
        self.start_spinbox.valueChanged.connect(
            self.notify_start_value_changed)
        self.end_spinbox.valueChanged.connect(self.notify_end_value_changed)

        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.start_spinbox)
        layout.addWidget(self.end_spinbox)

        self.value_changed_signal = self.valueChanged
예제 #2
0
파일: widgets.py 프로젝트: shiva16/openalea
    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.spinbox = QtGui.QSpinBox()

        # Fill background to avoid to see text or widget behind
        self.setAutoFillBackground(True)

        AbstractIntWidget.__init__(self)

        # To be compatible with tree or table views, slider must keep focus
        self.slider.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setMinimumHeight(22)
        self.spinbox.setMinimumHeight(18)
        self.slider.setMinimumHeight(18)

        self.slider.valueChanged.connect(self.spinbox.setValue)
        self.spinbox.valueChanged.connect(self.slider.setValue)
        self.slider.valueChanged.connect(self.valueChanged)

        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.spinbox)
        layout.addWidget(self.slider)

        self.value_changed_signal = self.valueChanged
예제 #3
0
    def make_widget(self, typ, value, parent):
        """ Take this value and type and make me a nice widget please.
        The widget is wrapped in a SenderWidget and can be accessed through
        the widget.inner attribute."""
        w = None
        if typ == bool:
            w = QtGui.QCheckBox(parent)
            w.setCheckState(
                QtCore.Qt.Checked if value else QtCore.Qt.Unchecked)
        elif typ == tuple:
            w = QtGui.QLineEdit(str(value), parent)
        elif typ == int:
            w = QtGui.QSpinBox(parent)
            w.setRange(-10000, 10000)
            w.setSingleStep(1)
        elif typ == float:
            w = QtGui.QDoubleSpinBox(parent)
            w.setRange(-10000.0, 10000.0)
            w.setSingleStep(0.01)

        if w is not None:
            wrapper = SenderWidget(w, typ, self)
            wrapper.valueChanged.connect(self.__on_widget_changed)
            return wrapper