0

Python Plugin

I am trying to make a plugin using Python.  I have made my PACKAGE file as:

 

package: AardAnnotate
version: 1.0
rv: 3.6
requires: ''

modes:
  - file: AardAnnotate
    menu: Tools/AardAnnotate
    load: immediate

description: |
  <p>Custom RV annotations</p>

 

And have used the template Python app:

 

import rv.rvtypes
import rv.commands

class AardAnnotate(rv.rvtypes.MinorMode):
    "A simple example that shows how to make shift-Z start/stop playback"

    def togglePlayback(self, event):
       
        if rv.commands.isPlaying():
            rv.commands.stop()
        else:
            rv.commands.play()

    def __init__(self):
        rv.rvtypes.MinorMode.__init__(self)
        self.init("AardAnnotate",
                    [("key-down--Z", self.togglePlayback, "Z key")],
                    None)

def createMode():
    "Required to initialize the module. RV will call this function to create your mode."
    return AardAnnotate()

But this does nothing when I click on the menu item.  The documentation for Python is not very imformative and I don't know what I need to change to make it work.  Any help greatly appreciated!




pyhello-1.0.rvpkg

7 条评论

  • 0
    Avatar
    Jim Hourihan

    Are you using version 3.6? Python is only in 3.12.11 or later. Its still in beta. The "rv" line in your PACKAGE file should say 3.12.11.

    We've tried to make the reference manual explain  package creation in detail. This applies to either Python or Mu. When you say the documentation is not very informative, what information are you not finding? We'd like the manual to be as informative as possible.

    What is the name of your python file ? Your PACKAGE doesn't include the .py extension, for example: AardAnnotate.py. I'm attaching the pyhello project for you to try. This is the package that was sent out with the beta email announcement (linked above in the original post).

      -Jim

  • 0
    Avatar
    Dominique Kwiek

    Thanks for the help Jim.  The RV 3.12.11 fixed it.

    In terms of the documentation it would be nice to have some more thorough Python examples but I do appreciate that Python support is a new feature and Mu is fully documented.

  • 0
    Avatar
    Mary Ferrante

    Hello, I had a problem with the description. I copied and pasted that part from the manual, to find out what was the problem with that, and it turns out that even copying I get a YAML parsing error.

  • 0
    Avatar
    Ray K

    Hey Marianna, I'm a beginner too, and I had similar issues getting my package up and running. What I did was carefully read through the tutorial  in Chapter 7 in the reference manual, which outlines a super simple package. Once I had that up and running I could use that base to build my own stuff.

    If you're still having trouble you could even take a look at the PACKAGE file included with a working package. If you go to your RV->Plugins->Packages folder you can see the package files added to RV (they're the .rvpkg ones). You can unzip them and take a look at some working PACKAGE files, and try to copy their structure.

    Ray

  • 0
    Avatar
    Mary Ferrante

    The first time it was the indentation in the "modes" but now, I still get it and I don't know why. Are there any rules for the name of the scripts, packages and so on?

  • 0
    Avatar
    Alan Trombla

    Hi Marianna,

    If you can attach your Package (the .rvpkg file, ideally) here, we'd be happy to look it over.

    Alan

  • 0
    Avatar
    Mary Ferrante

    I found the error I guess:

    modes:
      - file: AardAnnotate
        menu: Tools/AardAnnotate
        load: immediate

    the - symbol before "file" was actually causing the error. Is it supposed to be there?

    Thank you both for your help,
    Mary

请先登录再写评论。