Skip to content

IOT instruction with list in guiclass #690

@multimeric

Description

@multimeric

This relates to #674 as I'm testing guiclass.

Code

from dataclasses import field
from magicgui.experimental import guiclass

@guiclass
class MyDataclass:
    colors: list[str] = field(default_factory=list)

if __name__ == '__main__':
    obj = MyDataclass()
    obj.gui.show(run=True)

Environment (please complete the following information):

  • OS: Ubuntu 22.04
  • backend: pyqt5-qt5==5.15.16
  • magicgui version: magicgui==0.10.0

Steps

  1. Run the app
  2. Click on the plus to add a new list item
  3. Click on the minus button

Image

Result

Traceback (most recent call last):
  File "src/psygnal/_signal.py", line 1279, in _run_emit_loop
  File "src/psygnal/_signal.py", line 1308, in _run_emit_loop_immediate
  File "src/psygnal/_weak_callback.py", line 355, in cb
  File "/home/migwell/.local/share/QGIS/QGIS3/profiles/default/python/plugins/MultiBandRaster/.venv/lib/python3.10/site-packages/magicgui/widgets/_concrete.py", line 752, in _remove_me
    self._pop_widget(self.index(widget))
  File "/usr/lib/python3.10/_collections_abc.py", line 1080, in index
    raise ValueError
ValueError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/migwell/.local/share/QGIS/QGIS3/profiles/default/python/plugins/MultiBandRaster/.venv/lib/python3.10/site-packages/magicgui/widgets/bases/_value_widget.py", line 69, in _on_value_change
    self.changed.emit(value)
  File "src/psygnal/_signal.py", line 1201, in emit
  File "src/psygnal/_signal.py", line 1296, in _run_emit_loop
  File "src/psygnal/_signal.py", line 1279, in _run_emit_loop
  File "src/psygnal/_signal.py", line 1308, in _run_emit_loop_immediate
  File "src/psygnal/_weak_callback.py", line 355, in cb
  File "/home/migwell/.local/share/QGIS/QGIS3/profiles/default/python/plugins/MultiBandRaster/.venv/lib/python3.10/site-packages/magicgui/widgets/_concrete.py", line 752, in _remove_me
    self._pop_widget(self.index(widget))
  File "/usr/lib/python3.10/_collections_abc.py", line 1080, in index
    raise ValueError
psygnal._exceptions.EmitLoopError: 

While emitting signal 'magicgui.widgets.PushButton.changed', an error occurred in a callback:

  ValueError: 
  ------------

  SIGNAL EMISSION: 
    /home/migwell/.local/share/QGIS/QGIS3/profiles/default/python/plugins/MultiBandRaster/.venv/lib/python3.10/site-packages/magicgui/backends/_qtpy/application.py:29 in _mgui_run
      return app.exec_()
    /home/migwell/.local/share/QGIS/QGIS3/profiles/default/python/plugins/MultiBandRaster/.venv/lib/python3.10/site-packages/magicgui/widgets/bases/_value_widget.py:69 in _on_value_change
      self.changed.emit(value)  # <-- SIGNAL WAS EMITTED HERE

  CALLBACK CHAIN:
    src/psygnal/_signal.py:1279 in _run_emit_loop
    ... 3 more frames ...
    /usr/lib/python3.10/_collections_abc.py:1080 in index
      raise ValueError  # <-- ERROR OCCURRED HERE 

      Local variables:
               value = _ListEditChildWidget(value='', annotation=None, name='')
               start = 0
                stop = None
                   i = 2
                   v = PushButton(value=False, annotation=None, name='plus')
[1]    759116 IOT instruction (core dumped)   

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions