Skip to content

Error when closing and re-opening the plugin #22

@jo-mueller

Description

@jo-mueller

Hi @JoOkuma ,

I'm getting an error when I open, close and re-open the plugin. The error is this:

        self = <Container ()>
     97 self._viewer.bind_key("X", self._cancel_annot)

File ~\Anaconda3\envs\pytorch\lib\site-packages\napari\utils\key_bindings.py:286, in bind_key(keymap={'C': <bound method SAMWidget._on_confirm_mask of <Container ()>>, 'X': <bound method SAMWidget._cancel_annot of <Container ()>>}, key='C', func=<bound method SAMWidget._on_confirm_mask of <Container ()>>, overwrite=False)
    283     key = normalize_key_combo(key)
    285 if func is not None and key in keymap and not overwrite:
--> 286     raise ValueError(
        trans = <napari.utils.translations.TranslationBundle object at 0x000002265A114730>
        key = 'C'
    287         trans._(
    288             'key combination {key} already used! specify \'overwrite=True\' to bypass this check',
    289             deferred=True,
    290             key=key,
    291         )
    292     )
    294 unbound = keymap.pop(key, None)
    296 if func is not None:

ValueError: key combination C already used! specify 'overwrite=True' to bypass this check

To reproduce:

Open the plugin in napari, close it again, and re-open it.

Fix

The error message points to this line in the code. Adding an overwrite=True to this line fixes it.

PR coming :)

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