Skip to content

Commit

Permalink
Add tick_interval attribute to UISliderWidget class
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornall committed Dec 23, 2024
1 parent a375e9b commit 1313217
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions eqt/ui/UISliderLEditWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, minimum=0.0, maximum=1.0, step_size=1.0, scale_factor=1.0):
self.maximum = maximum
self.scale_factor = scale_factor
self.step_size = step_size
self.tick_interval = self.step_size * self.scale_factor

# Configure the QSlider
self.slider = QSlider()
Expand Down Expand Up @@ -72,16 +73,16 @@ def get_slider_value(self):
return self.slider.value()

def get_line_edit_value(self):
return float(self.line_edit.text())
return self.line_edit.text()

def update_slider(self):
state = self.validator.validate(self.line_edit.text(), 0)
if state[0] == QtGui.QDoubleValidator.Acceptable:
line_edit_value = self.get_line_edit_value()
line_edit_value = float(self.get_line_edit_value())
self.slider.setValue(line_edit_value)
else:
self.line_edit.setText(str(self.minimum))
line_edit_value = self.get_line_edit_value()
line_edit_value = float(self.get_line_edit_value())
self.slider.setValue(line_edit_value)

def update_line_edit(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/dialog_example_uislider.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def openFormDialog(self):
line_edit = QtWidgets.QLineEdit()
max_label = QtWidgets.QLabel()
uislider = UISliderWidget.UISliderWidget(line_edit, max_label, minimum=0.0, maximum=100.0,
step_size=1.0)
scale_factor=10.0)

# add to the form widget
dialog.addWidget(uislider, 'QSlider 1:', 'input_slider1')
Expand Down

0 comments on commit 1313217

Please sign in to comment.