AnyWave:WritePythonScripted

From WikiMEG
Revision as of 11:14, 30 July 2014 by Bruno (Talk | contribs)

Jump to: navigation, search

Introduction

This section targets people who have a good knowledge and practice of the Python programming language.
The purpose is to explain how to write a Python script that will be the heart of a plug-in executed by AnyWave.
We will also explain how to create a text file to describe our plug-in to AnyWave

The AnyWave-Python API (Application Programming Interface) consists in a Python module that is automatically imported in the Python environment by AnyWave.

Where to start?

The first thing to do is to create the basic structure for a plug-in.
A Python Scripted plug-in is very simple, it is a folder containing at least two files:

  • desc.txt (a text file describing the plug-in)
  • __main__.py (the Python code)

Now, place the folder containing the two files in a location where AnyWave will be able to load it.

The prefered location is the user's AnyWave directory.

Python location.png

Check that the plug-in is available

Loaded plugin.png

The Python module

AnyWave will execute the Python plug-in in a separated Python environment which is embedded in the application.

A Python interpreter will execute the script '__main.py__' of our plug-in.

Before the script is being executed, AnyWave will do some initializing like importing a module named anywave in the Python's environment.

The module provides methods and attributes that will allow interactions between AnyWave and the Python script's environment.