MCPcopy Create free account
hub / github.com/LabPy/lantz / change_units

Method change_units

lantz/ui/widgets.py:782–799  ·  view source on GitHub ↗

Update displayed suffix and stored units.

(self, new_units)

Source from the content-addressed store, hash-verified

780 self.change_limits(None)
781
782 def change_units(self, new_units):
783 """Update displayed suffix and stored units.
784 """
785 if new_units is None:
786 return
787 try:
788 rescaled = self.value().to(new_units)
789 except ValueError:
790 # incompatible units
791 return None
792 else:
793 if hasattr(self, 'setSuffix'):
794 self.setSuffix(' ' + str(new_units.units))
795
796 self.change_limits(new_units)
797 self._units = new_units
798
799 self.setValue(rescaled)
800
801 def change_limits(self, new_units):
802 """Change the limits (range) of the control taking the original values

Callers 2

keyPressEventMethod · 0.95
bind_featMethod · 0.95

Calls 3

valueMethod · 0.95
change_limitsMethod · 0.95
setValueMethod · 0.95

Tested by

no test coverage detected