Exemple #1
0
def make_spinbox(min_value=None,
                 max_value=None,
                 value=None,
                 limits=None,
                 prefix=None,
                 suffix=None,
                 single_step=None,
                 parent=None):
    ret = QtWidgets.QSpinBox(parent)
    if min_value is not None:
        ret.setMinimum(min_value)
    if max_value is not None:
        ret.setMaximum(max_value)
    if limits is not None:
        ret.setMinimum(limits[0])
        ret.setMaximum(limits[1])
    if prefix is not None:
        ret.setPrefix(prefix)
    if suffix is not None:
        ret.setSuffix(suffix)
    if single_step is not None:
        ret.setSingleStep(single_step)
    if value is not None:
        ret.setValue(value)

    return ret
factory.append_classinfo_binding(
        QtWidgets.QSlider, SliderParameterBinding)

factory.append_predicate_binding(
        lambda target: target is None, TargetlessParameterBinding)

if __name__ == "__main__":
    import mock

    app = QtWidgets.QApplication([])

    device = mock.MagicMock()
    profile = mock.MagicMock()
    display_mode = util.CONFIG
    write_mode = util.COMBINED
    target = QtWidgets.QSpinBox()

    d = dict(device=device)

    binding = factory.make_binding(device=device, profile=profile, display_mode=display_mode,
            write_mode=write_mode, target=target)

    target2 = util.DelayedDoubleSpinBox()
    binding2 = factory.make_binding(device=device, profile=profile, display_mode=display_mode,
            write_mode=write_mode, unit_name="the_unit_name", target=target2)

    target.show()
    target2.show()

    app.exec_()