Proof of Concept approach for plugins providing actions - #103
Conversation
alisterburt
left a comment
There was a problem hiding this comment.
this looks really interesting, definitely a goal we want to push for!
I'm not sure why some of the actions are lambda functions whilst others are the callback method itself - is this a bind to the instance vs. class thing?
It was just using what was there before, wasn't thought out beyond that. We could standardize and make it a little more readable |
|
to expand on that a bit: |
|
very useful @tlambert03 - made me realise a few things, thanks! |
Here is a potential approach for allowing plugins to providing actions such as keybindings that could then be registered by the action manager that @tlambert03 and I came up with. The big goal was to remove to explicit calls to
viewer.bind_keyand the need for the plugin to clean up its own keybindings and have the "bind" and "unbind" be done by napari through the actions manager, so the shortcut can be changed etc.The main idea is that there is a new hook_specification
napari_register_actionsthat allows a list of actions to be passed. This approach was a little more inspired by how we used to think about providing defaults with the actions themselves, but we should really follow the APIs that @Carreau has already been developing and using in napari, but now just be able to pass plugin dock widgets to these functions and register shortcuts to them.What we wrote could look something like this
We will need to think about how napari can receive these actions, and how/ when they will get called, but that is on the napari side, not the plugin side.
Curious what @Carreau thinks about this. Might probably be good to have a dedicated meeting with @Carreau @ppwadhwa @goanpeca too to discuss this as we start thinking about it more!! cc @jni @alisterburt