Skip to content

[ENHANCEMENT] add simple plugin stubs to this repo #12

Open

Description

@csoeller

The suggestion

We need some info/examples on plugin strategies IMHO.

It has become clear to me that we need a bit of info how to do

  • a visgui plugin
  • a dh5view plugin
  • a pymeacquire plugin

Rather than having long doc diatribes I would suggest adding stub templates according to current wisdom to this repo, including adding an example init file with a plugin example for PYMEAcquire and an associated install example. This should encapsulate current best practice and be updated with PYME refinements/changes over time.

I cannot think of a better place than this repo but feel free to suggest alternatives.

Current stub ideas

Here are a couple of stubs that could do with David's input for improvement where necessary, e.g. should some of these be derived from the plugin base class etc?

They could probably show off a little more functionality but this could be a starting point.

I will be happy to create a PR if there is general agreement that is could be a reasonable idea.

dh5view_template_plugin.py:

class MyPlugin:
    def __init__(self, dsviewer):
        self.dsviewer = dsviewer

        dsviewer.AddMenuItem('Experimental>MyMenuSection', "Do something", self.OnDoSomething)

    def OnDoSomething(self, event):
        pass


def Plug(dsviewer):
    """Plugs this module into the gui"""
    MyPlugin(dsviewer)

visgui_template_plugin.py:

# import numpy as np

class MyPlugin:
    def __init__(self, visFr):
        self.visFr = visFr

        visFr.AddMenuItem('Experimental>MyMenuSection', "Do something", self.OnDoSomething)

    def OnDoSomething(self, event):
        pass

def Plug(visFr):
    """Plugs this module into the gui"""
    MyPlugin(visFr)

Activity

  1. csoeller commented on Mar 27, 2021

    @csoeller
    Author

    PS - If it is thought that it may be better to keep this repo just an empty shell I am happy to create a pyme-plugin-example repo that has some simple examples as described above. Still would not mind some feedback how to properly write these plugins either way.

  2. zacsimile commented on Mar 28, 2021

    @zacsimile
    Member

    I think it makes sense to include a stubs or examples folder. The alternative is to include these in their respective sections in the docs (e.g. https://python-microscopy.org/doc/ExtendingVisGUI.html and https://python-microscopy.org/doc/ExtendingDsviewer.html). It would be neat if we can also include a PYMEAcquire example.

  3. csoeller commented on Mar 28, 2021

    @csoeller
    Author

    Great, would be good to get @barentine's view on this as I can either (a) make a PR against this repo or (b) fork this repo into something like pyme-plugin-example that gets the example minimal plugins. The upside would be that it keeps this repo clean but it may also create maintenance issues down the line.

  4. barentine commented on Mar 28, 2021

    @barentine
    Member

    Would certainly be great to get more of this into the formal docs.

    I think it's probably helpful to keep stubs somewhere in this repo if we can, otherwise we add maintenance as you say and also it gets harder to see what the advantage is over just looking at another existing plugin.

    I'm not a huge fan of an examples folder - it's not a big deal, but I think even our existing pyme-plugin/package_name/plugins/ filetree stuff that we copy into the right location during install_plugin feels a little superfluous and maybe messier than just adding filenames to a dict in install_plugin itself or so which people already have to edit.

    As far as where to put the stubs, I could see putting them all in readme.md, or just in an example.py directly in the folder they're supposed to go in so they can just be edited/file renamed like an actual template.

    Thanks both for thinking about this/working on it - sorry I'm a bit MIA at the moment - submitting my thesis in a couple weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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