Difference between revisions of "AnyWave:WritePythonScripted"

From WikiMEG
Jump to: navigation, search
(Writing the desc.txt file)
Line 17: Line 17:
 
category = Process:Python:PyExample
 
category = Process:Python:PyExample
 
</syntaxhighlight>
 
</syntaxhighlight>
The category line is optional. It tells AnyWave where the plug-in will appear in the menus. Here, we decided to make it appear under the Python sub-menu in the Processes main menu.<br />
+
The syntax is to set keywords and values.<br />
Finally, the plug-in name will be PyExample Plugin.
+
Here we have three keywords (name, description, category).<br />
 +
Two keywords are mandatory : name and description. Other keywords are optional.<br />
 +
==keywords==
 +
name : The plugin name used by Anywave (here PyExample Plugin).<br />
 +
description : a brief description of what the plugin does.<br />
 +
category (optional): It tells AnyWave where the plug-in will appear in the menus. Here, we decided to make it appear under the Python sub-menu in the Processes main menu.<br />
  
 
The category feature is usefull to separate plug-ins that won't really do some calculation but convert data to another format or launch external tools.
 
The category feature is usefull to separate plug-ins that won't really do some calculation but convert data to another format or launch external tools.

Revision as of 16:28, 31 May 2017

Introduction

Here we assume that you have Python 2.7 installed on your system with at least the numpy package.

Configuring AnyWave to use Pyhton

It's very simple, just open the Preferences UI:

PythonPrefs.png

This is a Windows version of AnyWave on which we are using Anaconda Python package. The path is the location of the Python interpreter.
That's it, your are ready to use Python plugins.

What is a Python plugin?

It's a folder containing at least two files:

  • __main__.py Python code file.
  • desc.txt Text file giving information about the plugin.

Writing the desc.txt file

We will write a Python example plugin which will be named PyExample, so the desc.txt file should look like:

name = PyExample Plugin
description = I'm a Python plugin
category = Process:Python:PyExample

The syntax is to set keywords and values.
Here we have three keywords (name, description, category).
Two keywords are mandatory : name and description. Other keywords are optional.

keywords

name : The plugin name used by Anywave (here PyExample Plugin).
description : a brief description of what the plugin does.
category (optional): It tells AnyWave where the plug-in will appear in the menus. Here, we decided to make it appear under the Python sub-menu in the Processes main menu.

The category feature is usefull to separate plug-ins that won't really do some calculation but convert data to another format or launch external tools. It could also be useful to classify signal processing algorithms.

Three category keywords are recognized:

  • Process : The plug-in will be set in the Processes menu with a subcategory and a name, for example 'Process:Correlation:Compute correlation'
  • File: The plug-in will be set in the File Menu under the Export sub-menu. Example : 'File:Export to file.'
  • View: The plug-in will be set in the View Menu. Example : 'View:Launch 3D viewer'

If no category is specified, AnyWave will set the plug-in in the Processes menu using the name defined in the file.