Skip to content

DriverTestWidget.widgets_values_as_dict() broken #67

Open

Description

@thibaudruelle

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})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions