Update displayed suffix and stored units.
(self, new_units)
| 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 |
no test coverage detected