jacopoabramo / napari-live-recording

General-purpouse camera capture plugin for data streaming to napari
MIT License
22 stars 6 forks source link

Attribute Error with __module__ #25

Closed mshnschnko closed 1 year ago

mshnschnko commented 1 year ago

I have this error when i try to activate this plugin


AttributeError                            Traceback (most recent call last)
File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\napari\_qt\menus\plugins_menu.py:105, in PluginsMenu._add_plugin_actions.<locals>._add_toggle_widget(key=('napari-live-recording', 'Live recording'), hook_type='dock')
    102     return
    104 if hook_type == 'dock':
--> 105     self._win.add_plugin_dock_widget(*key)
        key = ('napari-live-recording', 'Live recording')
        self._win = <napari._qt.qt_main_window.Window object at 0x00000161BE726A50>
        self = <napari._qt.menus.plugins_menu.PluginsMenu object at 0x00000161BFD27BE0>
    106 else:
    107     self._win._add_plugin_function_widget(*key)

File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\napari\_qt\qt_main_window.py:811, in Window.add_plugin_dock_widget(self=<napari._qt.qt_main_window.Window object>, plugin_name='napari-live-recording', widget_name='Live recording', tabify=False)
    808         wdg = wdg._magic_widget
    809     return dock_widget, wdg
--> 811 wdg = _instantiate_dock_widget(
        Widget = <class 'napari_live_recording.NapariLiveRecording'>
        self = <napari._qt.qt_main_window.Window object at 0x00000161BE726A50>
    812     Widget, cast('Viewer', self._qt_viewer.viewer)
    813 )
    815 # Add dock widget
    816 dock_kwargs.pop('name', None)

File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\napari\_qt\qt_main_window.py:1465, in _instantiate_dock_widget(wdg_cls=<class 'napari_live_recording.NapariLiveRecording'>, viewer=Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoo...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}))
   1460             break
   1461         # cannot look for param.kind == param.VAR_KEYWORD because
   1462         # QWidget allows **kwargs but errs on unknown keyword arguments
   1463 
   1464 # instantiate the widget
-> 1465 return wdg_cls(**kwargs)
        kwargs = {'napari_viewer': Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoom=1.0, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(1.0, 1.0), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=2, ndisplay=2, last_used=0, range=((0, 2, 1), (0, 2, 1)), current_step=(0, 0), order=(0, 1), axis_labels=('0', '1')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[], help='', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x00000161B9B79260>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={})}
        wdg_cls = <class 'napari_live_recording.NapariLiveRecording'>

File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\napari_live_recording\__init__.py:11, in NapariLiveRecording.__init__(self=<napari_live_recording.NapariLiveRecording object>, napari_viewer=Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoo...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}))
      9 self.app = QApplication.instance()
     10 self.mainController = MainController()
---> 11 self.anchor = ViewerAnchor(napari_viewer, self.mainController)
        self.mainController = <napari_live_recording.control.MainController object at 0x00000161C8B688B0>
        self = <napari_live_recording.NapariLiveRecording object at 0x00000161C8B47B50>
        napari_viewer = Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoom=1.0, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(1.0, 1.0), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=2, ndisplay=2, last_used=0, range=((0, 2, 1), (0, 2, 1)), current_step=(0, 0), order=(0, 1), axis_labels=('0', '1')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[], help='', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x00000161B9B79260>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={})
     12 self.setLayout(self.anchor.mainLayout)
     13 self.app.lastWindowClosed.connect(self.on_close_callback)

File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\napari_live_recording\ui\__init__.py:40, in ViewerAnchor.__init__(self=<napari_live_recording.ui.ViewerAnchor object>, napari_viewer=Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoo...ouse_drag_gen={}, _mouse_wheel_gen={}, keymap={}), mainController=<napari_live_recording.control.MainController object>)
     38 self.selectionWidget.setDeviceSelectionWidget(list(devicesDict.keys()))
     39 self.selectionWidget.setAvailableCameras(list(devicesDict.keys()))
---> 40 self.recordingWidget = RecordHandling()
        self = <napari_live_recording.ui.ViewerAnchor object at 0x00000161C8B4CC90>
        RecordHandling = <class 'napari_live_recording.ui.widgets.RecordHandling'>
     41 verticalSpacer = QSpacerItem(0, 1, QSizePolicy.Minimum, QSizePolicy.Minimum)
     42 self.mainLayout.addWidget(self.selectionWidget.group)

File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\napari_live_recording\ui\widgets.py:397, in RecordHandling.__init__(self=<napari_live_recording.ui.widgets.RecordHandling object>)
    394 self.layout = QGridLayout()
    396 self.formatLabel = QLabel("File format")
--> 397 self.formatComboBox = QEnumComboBox(enum_class=FileFormat)
        self = <napari_live_recording.ui.widgets.RecordHandling object at 0x00000161C8B6A680>
        QEnumComboBox = <class 'superqt.combobox._enum_combobox.QEnumComboBox'>
    398 self.formatLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
    400 self.folderTextEdit = QLineEdit(
    401     os.path.join(os.path.expanduser("~"), "Documents")
    402 )

File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\superqt\combobox\_enum_combobox.py:42, in QEnumComboBox.__init__(self=<superqt.combobox._enum_combobox.QEnumComboBox object>, parent=None, enum_class=<enum 'FileFormat'>, allow_none=False)
     40 self._allow_none = False
     41 if enum_class is not None:
---> 42     self.setEnumClass(enum_class, allow_none)
        self = <superqt.combobox._enum_combobox.QEnumComboBox object at 0x00000161C8B6A8C0>
        enum_class = <enum 'FileFormat'>
        allow_none = False
     43 self.currentIndexChanged.connect(self._emit_signal)

File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\superqt\combobox\_enum_combobox.py:53, in QEnumComboBox.setEnumClass(self=<superqt.combobox._enum_combobox.QEnumComboBox object>, enum=<enum 'FileFormat'>, allow_none=False)
     51     super().addItem(NONE_STRING)
     52 names = map(_get_name, self._enum_class.__members__.values())
---> 53 _names = dict.fromkeys(names)  # remove duplicates/aliases, keep order
        names = <map object at 0x00000161D146E560>
     54 super().addItems(list(_names))

File E:\IMAGEJ24\napari_24\.venv\Lib\site-packages\superqt\combobox\_enum_combobox.py:16, in _get_name(enum_value=<FileFormat.ImageJ TIFF: 1>)
     13 def _get_name(enum_value: Enum):
     14     """Create human readable name if user does not implement `__str__`."""
     15     if (
---> 16         enum_value.__str__.__module__ != "enum"
        enum_value = <FileFormat.ImageJ TIFF: 1>
        enum_value.__str__ = <method-wrapper '__repr__' of FileFormat object at 0x00000161C8B4C780>
     17         and not enum_value.__str__.__module__.startswith("shibokensupport")
     18     ):
     19         # check if function was overloaded
     20         name = str(enum_value)
     21     else:

AttributeError: 'method-wrapper' object has no attribute '__module__'```
jacopoabramo commented 1 year ago

Hi @mshnschnko, sorry for the late reply.

I can't seem to replicate the error. Could you tell me which python version are you using?

mshnschnko commented 1 year ago

@jacopoabramo I used python 3.11.4. After your comment, I checked for python 3.10 and everything worked. The problem really was this.

jacopoabramo commented 1 year ago

Ah, I see. Good to know, then I'll close the issue