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

Method set_selection

pyxrf/gui_module/useful_widgets.py:850–900  ·  view source on GitHub ↗

Set the selected range. The function may be used to set only lower or upper boundary. The function will not emit `selection_changed` signal. Call `emit_selection_changed()` method to emit the signal. Parameters ---------- value_low: float, int or Non

(self, *, value_low=None, value_high=None)

Source from the content-addressed store, hash-verified

848 return self.set_selection(value_low=new_value_low, value_high=new_value_high)
849
850 def set_selection(self, *, value_low=None, value_high=None):
851 """
852 Set the selected range. The function may be used to set only lower or upper
853 boundary. The function will not emit `selection_changed` signal.
854 Call `emit_selection_changed()` method to emit the signal.
855
856 Parameters
857 ----------
858 value_low: float, int or None
859 lower boundary of the selected range. If `None`, then the lower boundary
860 is not changed. If `value_low` is outside the full range, then it is clipped.
861 value_high: float, int or None
862 upper boundary of the selected range. If `None`, then the upper boundary
863 is not changed. If `value_low` is outside the full range, then it is clipped.
864
865 Returns
866 -------
867 True - selected range changed, False - selected range stayed the same
868 """
869 old_low, old_high = self._value_low, self._value_high
870
871 if value_low is not None or value_high is not None:
872 self._adjust_min_diff()
873 if value_low is not None:
874 value_low = self._convert_type(value_low)
875 value_low = max(min(value_low, self._range_high), self._range_low)
876 self._value_low = value_low
877 if value_high is not None:
878 value_high = self._convert_type(value_high)
879 value_high = max(min(value_high, self._range_high), self._range_low)
880 self._value_high = value_high
881 # Exceptional case when the selection is smaller than the minimum selected
882 # range (or negative). Adjust the range: start at the specified 'low' value
883 # and cover the minimum selectable range; if 'high' value exceeds the top
884 # of the full range, then shift the selected range downwards to fit within
885 # the full range
886 if self._value_high < self._value_low + self._range_min_diff:
887 self._value_high = self._value_low + self._range_min_diff
888 if self._value_high > self._range_high:
889 self._value_high = self._range_high
890 self._value_low = self._range_high - self._range_min_diff
891 self._adjust_validators()
892 if value_low is not None:
893 self.sld_min_value.setValue(self.sld_n_steps - self._value_to_slider(self._value_low))
894 self.le_min_value.setText(self._format_value(self._value_low))
895 if value_high is not None:
896 self.sld_max_value.setValue(self._value_to_slider(self._value_high))
897 self.le_max_value.setText(self._format_value(self._value_high))
898
899 # Return True if selection changed
900 return (old_low != self._value_low) or (old_high != self._value_high)
901
902 def reset(self):
903 """

Callers 15

fill_tableMethod · 0.95
_accept_value_lowMethod · 0.95
_accept_value_highMethod · 0.95
set_rangeMethod · 0.95
resetMethod · 0.95
test_RangeManager_1Function · 0.95
test_RangeManager_2Function · 0.95
test_RangeManager_3Function · 0.95
test_RangeManager_4Function · 0.95
test_RangeManager_5Function · 0.95
test_RangeManager_7Function · 0.95
test_RangeManager_9Function · 0.95

Calls 6

_adjust_min_diffMethod · 0.95
_convert_typeMethod · 0.95
_adjust_validatorsMethod · 0.95
_value_to_sliderMethod · 0.95
_format_valueMethod · 0.95
setTextMethod · 0.80

Tested by 7

test_RangeManager_1Function · 0.76
test_RangeManager_2Function · 0.76
test_RangeManager_3Function · 0.76
test_RangeManager_4Function · 0.76
test_RangeManager_5Function · 0.76
test_RangeManager_7Function · 0.76
test_RangeManager_9Function · 0.76