LabPy / lantz

Lantz is an automation and instrumentation toolkit with a clean, well-designed and consistent interface. It provides a core of commonly used functionalities for building applications that communicate with scientific instruments allowing rapid application prototyping, development and testing. Lantz benefits from Python’s extensive library flexibility as a glue language to wrap existing drivers and DLLs.
http://lantz.readthedocs.org/
Other
134 stars 65 forks source link

In case of DictFeat, DriverTestWidget.update_on_change() has no effect #66

Open thibaudruelle opened 8 years ago

thibaudruelle commented 8 years ago

Context: I ran start_test_app on an instance of a custom driver which contained a DictFeat and unchecked its "Update on change" checkbox. It had no effect on the behavior of the widget.

Probable origin: In case of a DictFeat, LabeledFeatWidget._widget is a DictFeatWidget, which doesn't have a value_to_feat method. As a result, when DriverTestWidget.update_on_change() runs widget._widget._update_on_change = new_state, the _update_on_change property of DictFeatWidget is updated instead of the _update_on_change property of DictFeatWidget._value_widget.

Probable fix: add an if isinstance(widget._widget, DictFeatWidget) statement to DriverTestWidget.update_on_change()

Proposed fix: rewrite DriverTestWidget.update_on_change() as

def update_on_change(self, new_state):
        """Set the 'update_on_change' flag to new_state in each writable widget
        within this widget. If True, the driver will be updated after each change.
        """

        for widget in self.writable_widgets:
            if isinstance(widget._widget, DictFeatWidget):
                widget._widget._value_widget._update_on_change = new_state
            else:
                widget._widget._update_on_change = new_state