My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SpyderPlugins  
Plugin development
Updated Jan 15, 2014 by techtonik@gmail.com

Spyder plugin development


Introduction

Spyder plugins are importable Python modules that may use internal API to do different stuff in IDE. Spyder goal is to be reusable set of components and widgets, so a lot of things is made with plugins. For example, code editor and python console are plugins. Object inspector, history browser and so on. You can see them here.

There are two type of plugins in Spyder:

  • core plugins - these are standard Spyder components located in spyderlib.plugins module. They are explicitly imported like usual Python modules.
  • external plugins - are discovered and imported dynamically, so they should follow naming convention so that Spyder can find them. External plugins are also initialized later all at once when some of the core set are already loaded [reference need].

Both plugin types should include class that inherits from the same base plugin class.

Plugin discovery

[more research is needed - ask techtonik@gmail.com if you feel capable]

Some software use directories for plugin installation and discovery. Spyder uses Python modules. Internal components are contained in spyderlib namespace and are imported explicitly. External and 3rd party plugins are automatically imported from certain predefined locations. One such location is spyderplugins module.

  • spyderplugins: this is what this page is about

To make your module appear in spyderplugins namespace, you need to make Spyder discover and import it first. In Spyder source code tree you can just drop your module into spyderplugins directory. This is more like hack than convenient plugin discovery interface, so proposal to fix this are welcome. One of the ideas is to inspect Python files without importing them with astdump modules and check if their interface is compatible. This will also allow Spyder to enable/disable plugins from config menu.

The module spyderplugins includes third-party plugins of several kinds.

In Spyder v2.0, any kind of plugin may be created in the module spyderplugins. These third-party plugins may communicate with other Spyder components through the plugin interface (see spyderlib/plugins/__init__.py).

I/O Spyder plugins

How to create your own I/O Spyder plugins:

  • Create a Python module named io_foobar.py where foobar is the name of your plugin
  • Write your loading function and/or your saving function:
    • load:
      • input is a string: filename
      • output is a tuple with two elements: dictionary containing at least one element (key is the variable name) and error message (or None)
    • save:
      • input is a tuple with two elements: data (dictionary), filename
      • output is a string or None: error message or None if no error occured
  • Define the global variables FORMAT_NAME, FORMAT_EXT, FORMAT_LOAD and FORMAT_SAVE. See the example of DICOM images support:
  • http://code.google.com/p/spyderlib/source/browse/spyderplugins/io_dicom.py
  • More examples of load/save functions may be found here:
  • http://code.google.com/p/spyderlib/source/browse/spyderlib/utils/iofuncs.py

History

Spyder v1.1 supported only input/output plugins (modules starting with io_) which provided I/O functions for the variable explorer (Workspace and Globals explorer in v1.1, Variable explorer in v2.0). Spyder natively supports .mat, .npy, .txt, .csv, .jpg, .png and .tiff file formats out of the box. These input plugins allowed users to add their own types, like HDF5 files for example.

Other Spyder plugins

See the example of the pylint third-party plugin in Spyder v2.0.

Comment by project member tim.mich...@gmail.com, Jun 21, 2010

Hello, can one also create plugins that perform other actions such as data analysis or graphing?

Comment by project member pierre.raybaut, Sep 5, 2010

Of course, since v2.0 it's possible.

Powered by Google Project Hosting