Ask for new units using a dialog box and return them. :param current_units: current units or magnitude. :type current_units: Quantity
(current_units)
| 737 | |
| 738 | |
| 739 | def request_new_units(current_units): |
| 740 | """Ask for new units using a dialog box and return them. |
| 741 | |
| 742 | :param current_units: current units or magnitude. |
| 743 | :type current_units: Quantity |
| 744 | |
| 745 | """ |
| 746 | new_units = UnitInputDialog.get_units(current_units) |
| 747 | if new_units is None: |
| 748 | return None |
| 749 | |
| 750 | try: |
| 751 | return Q_(1, new_units) |
| 752 | except LookupError: |
| 753 | # cannot parse units |
| 754 | return None |
| 755 | |
| 756 | |
| 757 | @register_wrapper |
no test coverage detected