-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy path07google_code_wiki.from
87 lines (64 loc) · 5.05 KB
/
07google_code_wiki.from
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#summary Plugin development
#sidebar TOC
<wiki:comment>
!!WARNING!! The table below displays the navigation bar
!!WARNING!! Please don't touch it unless you know what you're doing.
</wiki:comment>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td colspan="9" align="center">http://wiki.spyderlib.googlecode.com/hg/Buttons/logo-mini.png</td>
</tr>
<tr>
<td>[http://code.google.com/p/spyderlib http://wiki.spyderlib.googlecode.com/hg/Buttons/home.png]</td>
<td>[http://code.google.com/p/spyderlib/downloads/list http://wiki.spyderlib.googlecode.com/hg/Buttons/download.png]</td>
<td>[http://code.google.com/p/spyderlib/wiki/Features http://wiki.spyderlib.googlecode.com/hg/Buttons/features.png]</td>
<td>[http://code.google.com/p/spyderlib/wiki/Screenshots http://wiki.spyderlib.googlecode.com/hg/Buttons/screenshots.png]</td>
<td>[http://packages.python.org/spyder/ http://wiki.spyderlib.googlecode.com/hg/Buttons/docs.png]</td>
<td>[http://code.google.com/p/spyderlib/wiki/Roadmap http://wiki.spyderlib.googlecode.com/hg/Buttons/roadmap.png]</td>
<td>[http://code.google.com/p/spyderlib/wiki/Support http://wiki.spyderlib.googlecode.com/hg/Buttons/support.png]</td>
<td>[http://code.google.com/p/spyderlib/wiki/Development http://wiki.spyderlib.googlecode.com/hg/Buttons/development_sel.png]</td>
<td>[http://spyder-ide.blogspot.com http://wiki.spyderlib.googlecode.com/hg/Buttons/blog.png]</td>
</tr>
</table>
= 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 [https://code.google.com/p/spyderlib/source/browse/#hg%2Fspyderlib%2Fplugins 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.
<wiki:comment>
[ ] check if plugins can be enabled/disabled
[ ] list of all lookup dirs
[ ] how to debug plugin discovery
[ ] API reference, version information
[ ] time when core plugins are initialized
[ ] time when external plugins are initialized
== Architecture ==
Spyder main window is de-facto storage for all Spyder state.
</wiki:comment>
== Plugin discovery ==
`[more research is needed - ask [email protected] 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.
<wiki:comment>TODO: check if prefix for plugin kind really affects loading or if it just a convention</wiki:comment>
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 [http://code.google.com/p/spyderlib/source/browse/spyderlib/plugins/__init__.py 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.