Module are extensions that can access to all the internal functionality of devparrot. They can create widgets, set hooks on internal events and so on.

Loading modules

Modules are loaded using the setuptools entry point system. A module must be declared in the "devparrot.module' entry point.

from setuptools import setup

      description="A personnal devparrot module"
      entry_points = {
        'devparrot.module' : ['mymodule = mymodule:MyModule']

It is also possible (mainly for test) to load a module using the "module load" command:

module load mymodule "mymodule:MyModule"

Writting module

A module is a class inheriting from BaseModule

The class will be instanciate using the module name given in the entrypoint (or as command argument)

from devparrot.core.modules import BaseModule

class MyModule(BaseModule):
    def __init__(self, name):
        BaseModule.__init__(self, name)

When a module is loaded, a module instance is always created, whatever it is activated or not. So be careful on what you make in the __init__ method.

A module can add options to the config system using the update_config static method:

class MyModule(BaseModule):
    def udpate_config(config):
        config.add_option("myoption", default="defaultValue")

Module activation

When a module is activate or deactivate, the correponding method are called. Must module will use those methods to create or destroy custom widget/helper.

class MyModule(BaseModule):
    def activate(self):

    def deactivate(self):

Respond to event

Modules can react to event generated by the devparrot's core.

Just defined a method starting by "on_" to handle the corresponding event.

class MyModule(BaseModule):
    def on_documentAdded(self, document):
        print("The document %s has just been added"%document)