Saturday, March 13, 2010

Python plugins easier to add

Before, adding new Python plugins required adding a new line in the pythonscripts.txt file. Each line described the location of the script, its name, description, icon, and when and how it should be displayed. This was not appropriate for a "plugin", because a user cannot simply download a plugin and expect it to work. In addition to downloading, editing the pythonscripts.txt file was also required.

New method is to require each Python script to have header a the top. Here is the header from the hillEquations.py plugin:

"""
category: Generate kinetics
name: Hill equations
description: generate the equilibrium rate equation for transcription
icon: Plugins/c/hillequation.png
menu: yes
specific for: Synthesis
tool: yes
"""

The header is quite self-explanatory (hopefully), except for the "menu" , "specific for", and "tool" attributes. The menu attribute is used to state whether or not this function should be listed in the menu of functions. The "specific for" attribute is used to indicate whether this function specifically applies to items belonging in a particular family. When items of this family are selected, the function will appear in the context menu (right-click). The tool attribute indicates whether or not to show this function on the side along with other tools (alternative interface to context menu).

All Python scripts must be located in one of the following folders, otherwise it will not be loaded.

/TinkerCell/py
/py

And all the scripts must have the suffix "py", otherwise they will be ignored.

Scripts can be uploaded and downloaded from: http://tinkercell.wikidot.com/python-scripts

No comments: