Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DriverTestWidget.widgets_values_as_dict() broken #67

Open
thibaudruelle opened this issue Apr 20, 2016 · 0 comments
Open

DriverTestWidget.widgets_values_as_dict() broken #67

thibaudruelle opened this issue Apr 20, 2016 · 0 comments

Comments

@thibaudruelle
Copy link

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})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant