The Wayback Machine - https://web.archive.org/web/20131024165518/http://code.google.com/p/spyderlib/wiki/SpyderPlugins
My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
SpyderPlugins  
Plugin development
Updated Jun 5, 2013 by techtonik@gmail.com

Spyder plugin development


Introduction

Spyder plugins are just importable Python files that use internal APIs to do different stuff in IDE. Spyder goal is to be reusable set of components and widgets, so a lot of stuff inside 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]

While many software use directories to distribute and find plugins, Spyder uses Python modules. It's own plugin are located under spyderlib namespace with all Spyder application. It can be used as a library. External plugins are expected to be found in a special importable module named.

  • spyderplugins: this is what this page is about

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

In Spyder v1.1, the only kind of plugin supported were the input/output plugins (modules starting with io_) which provide 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. These plugins allow users to add their own types, like HDF5 files for example.

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

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