MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / RangeManager

Class RangeManager

pyxrf/gui_module/useful_widgets.py:466–947  ·  view source on GitHub ↗

Width of the widgets can be set using `setMaximumWidth`. The size policy is set so that the widget may shrink if there is not enough space.

Source from the content-addressed store, hash-verified

464
465
466class RangeManager(QWidget):
467 """Width of the widgets can be set using `setMaximumWidth`. The size policy is set
468 so that the widget may shrink if there is not enough space."""
469
470 selection_changed = Signal(float, float, str)
471
472 def __init__(self, *, name="", add_sliders=False, slider_steps=10000, selection_to_range_min=0.001):
473 """
474 Class constructor for RangeManager
475
476 Parameters
477 ----------
478 add_sliders: bool
479 True - the widget will include sliders for controlling the range,
480 False - the widget will have no sliders without sliders
481 slider_steps: int
482 The number of slider steps. Determines the precision of the slider.
483 Default value is sufficient in most cases
484 selection_to_range_min: float
485 Minimum ratio of the selected range and total range. Must be floating
486 point number >=0. Used only when the value type is set to "float":
487 `self.set_value_type("float")`. Minimum selected range is always 1
488 when "int" value type is set.
489 """
490 super().__init__()
491
492 self._name = name
493
494 # Set the maximum number of steps for the sliders (resolution)
495 self.sld_n_steps = slider_steps
496 # Ratio of the minimum range and total range. It is used to compute
497 # the value of 'self._range_min_diff'. The widget will prevent
498 # range to be set to smaller value than 'self._range_min_diff'.
499 self._selection_to_range_min = selection_to_range_min
500
501 self._range_low = 0.0
502 self._range_high = 100.0
503 self._range_min_diff = (self._range_high - self._range_low) * self._selection_to_range_min
504 self._value_per_step = (self._range_high - self._range_low) / self.sld_n_steps
505 self._value_type = "float"
506
507 # The following values are used to keep the low and high of the range.
508 # Those values are 'accepted' values that reflect current selected range.
509 self._value_low = self._range_low
510 self._value_high = self._range_high
511
512 max_element_width = 200
513
514 self.le_min_value = LineEditExtended()
515 self.le_max_value = LineEditExtended()
516 self.validator_low = DoubleValidatorRelaxed()
517 self.validator_high = DoubleValidatorRelaxed()
518
519 self.le_min_value.setMaximumWidth(max_element_width)
520 self.le_min_value.textEdited.connect(self.le_min_value_text_edited)
521 self.le_min_value.textChanged.connect(self.le_min_value_text_changed)
522 self.le_min_value.editingFinished.connect(self.le_min_value_editing_finished)
523 self.le_max_value.setMaximumWidth(max_element_width)

Callers 13

test_RangeManager_1Function · 0.90
test_RangeManager_2Function · 0.90
test_RangeManager_3Function · 0.90
test_RangeManager_4Function · 0.90
test_RangeManager_5Function · 0.90
test_RangeManager_6Function · 0.90
test_RangeManager_7Function · 0.90
test_RangeManager_8Function · 0.90
test_RangeManager_9Function · 0.90
__init__Method · 0.85
fill_tableMethod · 0.85
fill_tableMethod · 0.85

Calls

no outgoing calls

Tested by 9

test_RangeManager_1Function · 0.72
test_RangeManager_2Function · 0.72
test_RangeManager_3Function · 0.72
test_RangeManager_4Function · 0.72
test_RangeManager_5Function · 0.72
test_RangeManager_6Function · 0.72
test_RangeManager_7Function · 0.72
test_RangeManager_8Function · 0.72
test_RangeManager_9Function · 0.72