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.
Context: I ran start_test_app on an instance of a custom driver which contained a DictFeat and clicked its "Update" button. The following error occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\lantz\ui\widgets.py", line 508, in <lambda>
update.clicked.connect(lambda x: target.update(self.widgets_values_as_dict()))
File "C:\Anaconda3\lib\site-packages\lantz\ui\widgets.py", line 585, in widgets_values_as_dict
for widget in self.writable_widgets}
File "C:\Anaconda3\lib\site-packages\lantz\ui\widgets.py", line 585, in <dictcomp>
for widget in self.writable_widgets}
AttributeError: 'LabeledFeatWidget' object has no attribute '_feat'
Probable origin: LabeledFeatWidget object has no attribute _feat, as opposed to the MixinWidget it contains.
Probable fix: Refer to the widget contained in LabeledFeatWidget instead. Also in case of a DictFeatWidget, refer to its value_widget and change return dictionary values to dictionaries as suitable for a DictFeat.
Proposed fix: rewrite DriverTestWidget.widgets_values_as_dict() as
def widgets_values_as_dict(self):
"""Return a dictionary mapping each writable feat name to the current
value of the widget.
"""
return ({widget._widget._value_widget._feat.name:
{widget._widget._value_widget._feat_key:
widget._widget.value()}
for widget in self.writable_widgets}
if isinstance(widget._widget, DictFeatWidget)
else {widget._widget._feat.name: widget._widget.value()
for widget in self.writable_widgets})
Context: I ran
start_test_app
on an instance of a custom driver which contained aDictFeat
and clicked its "Update" button. The following error occurred:Probable origin:
LabeledFeatWidget
object has no attribute_feat
, as opposed to theMixinWidget
it contains.Probable fix: Refer to the widget contained in
LabeledFeatWidget
instead. Also in case of aDictFeatWidget
, refer to itsvalue_widget
and change return dictionary values to dictionaries as suitable for aDictFeat
.Proposed fix: rewrite
DriverTestWidget.widgets_values_as_dict()
as