예제 #1
0
 def add_custom(
     self,
     label: str = "Other",
     typ: TypeStr = "string",
     default: None | float | str = None,
     regex: str | None = None,
 ):
     if typ == "string":
         self.widget_custom = widgets.LineEdit()
     elif typ == "int":
         self.widget_custom = widgets.SpinBox()
     elif typ == "float":
         self.widget_custom = widgets.DoubleSpinBox()
     else:
         raise ValueError(typ)
     # TODO: Enable this or add BAR radio and option.
     self.widget_custom.set_disabled()  # type: ignore
     if default is not None:
         self.widget_custom.set_value(default)  # type: ignore
     self.rb_other.setText(label)
     self.rb_other.toggled.connect(
         self.widget_custom.set_enabled)  # type: ignore
     self.widget_custom.value_changed.connect(  # type: ignore
         lambda: self.update_choice(True))
     if regex and typ == "string":
         self.widget_custom.set_regex_validator(regex)  # type: ignore
     layout = widgets.BoxLayout("horizontal")
     layout.add(self.rb_other)
     layout.add(self.widget_custom)
     self.box.add(layout)
예제 #2
0
 def _create_widget(self) -> widgets.DoubleSpinBox:
     widget = widgets.DoubleSpinBox()
     widget.set_range(*self.range)
     widget.setSingleStep(self.step)
     widget.setSuffix(self.unit)
     if self.value is not None:
         widget.set_value(self.value)
     return widget
예제 #3
0
def test_doublespinbox():
    widget = widgets.DoubleSpinBox()
    widget.set_disabled()
    widget.set_enabled()
    with open("data.pkl", "wb") as jar:
        pickle.dump(widget, jar)
    with open("data.pkl", "rb") as jar:
        widget = pickle.load(jar)
    repr(widget)
예제 #4
0
파일: dataset.py 프로젝트: timfl94/PrettyQt
 def __init__(self, label, default=None, min_val=None, max_val=None,
              unit="", step=0.1, slider=False, check=True):
     super().__init__(label, default=default, min_val=min_val,
                      max_val=max_val, unit=unit, check=check)
     self.widget = widgets.DoubleSpinBox()
     self.widget.set_range(min_val, max_val)
     self.widget.setSingleStep(step)
     self.widget.setSuffix(unit)
     if default is not None:
         self.widget.set_value(default)
예제 #5
0
 def __init__(self,
              title: str = "",
              parent: QtWidgets.QWidget | None = None):
     super().__init__(checkable=False, title=title)
     self.set_layout("vertical")
     self.rb_lineedit = widgets.RadioButton("String")
     self.lineedit = widgets.LineEdit()
     self.rb_spinbox = widgets.RadioButton("Number")
     self.spinbox = widgets.DoubleSpinBox()
     layout_lineedit = widgets.BoxLayout("horizontal")
     layout_lineedit.add(self.rb_lineedit)
     layout_lineedit.add(self.lineedit)
     layout_spinbox = widgets.BoxLayout("horizontal")
     layout_spinbox.add(self.rb_spinbox)
     layout_spinbox.add(self.spinbox)
     self.box.add(layout_lineedit)
     self.box.add(layout_spinbox)
     self.rb_spinbox.toggled.connect(self.spinbox.setEnabled)
     self.rb_spinbox.toggled.connect(self.lineedit.setDisabled)
     self.rb_lineedit.toggled.connect(self.lineedit.setEnabled)
     self.rb_lineedit.toggled.connect(self.spinbox.setDisabled)
     self.spinbox.value_changed.connect(self.on_value_change)
     self.lineedit.value_changed.connect(self.on_value_change)
     self.rb_lineedit.setChecked(True)
예제 #6
0
def test_doublespinbox():
    widget = widgets.DoubleSpinBox()
    widget.show()
    widget.close()