Change the limits (range) of the control taking the original values from the feat and scaling them to the new_units.
(self, new_units)
| 799 | self.setValue(rescaled) |
| 800 | |
| 801 | def change_limits(self, new_units): |
| 802 | """Change the limits (range) of the control taking the original values |
| 803 | from the feat and scaling them to the new_units. |
| 804 | """ |
| 805 | if not hasattr(self, 'setRange'): |
| 806 | return |
| 807 | |
| 808 | rng = self._feat.limits or (float('-inf'), float('+inf')) |
| 809 | if new_units: |
| 810 | conv = lambda ndx: Q_(rng[ndx], self._feat.units).to(new_units).magnitude |
| 811 | else: |
| 812 | conv = lambda ndx: rng[ndx] |
| 813 | |
| 814 | if len(rng) == 1: |
| 815 | self.setRange(0, conv(0)) |
| 816 | else: |
| 817 | self.setRange(conv(0), conv(1)) |
| 818 | if len(rng) == 3: |
| 819 | self.setSingleStep(conv(2)) |
| 820 | |
| 821 | def value(self): |
| 822 | """Get widget value and scale by units. |
no outgoing calls
no test coverage detected