Script Interfaces#
Both commands and input generator scripts can create user interfaces
using JSON syntax. For each option in the userOptions
list, Avogadro
will create appropriate labels, menus, text boxes, check boxes, etc.
Short Free-Form Text Parameters#
A short text string can be requested (e.g. for the “title” of an optimization) via:
{
"userOptions": {
"Parameter Name": {
"type": "string",
"default": "blah blah blah"
}
}
}
This will add a blank text box to the GUI, initialized with the text specified by default.
Existing files#
A script can ask for the absolute path to an existing file using the following option block:
{
"userOptions": {
"Parameter Name": {
"type": "filePath",
"default": "/path/to/some/file"
}
}
}
This will add an option to select a file to the GUI, initialized to the file pointed to by default.
Integer Values#
Scripts may request integer values from a specified range by adding a user-option of the following form:
{
"userOptions": {
"Parameter Name": {
"type": "integer",
"minimum": -5,
"maximum": 5,
"default": 0,
"prefix": "some text ",
"suffix": " units"
}
}
}
This block will result in a QSpinBox, configured as follows:
minimum and maximum indicate the valid range of integers for the parameter.
default is the integer value that will be shown initially.
(optional) prefix and suffix are used to insert text before or after the integer value in the spin box. This is handy for specifying units. Note that any prefix or suffix will be stripped out of the corresponding entry in the call to scripts, and just the raw integer value will be sent.
Floating-point values#
Scripts may request floating-point values from a specified range by adding:
{
"userOptions": {
"Parameter Name": {
"type": "integer",
"minimum": -5,
"maximum": 5,
"default": 0,
"prefix": "some text ",
"suffix": " units"
}
}
}
Boolean Parameters#
If a simple on/off value is needed, a boolean type option can be requested:
{
"userOptions": {
"Parameter Name": {
"type": "boolean",
"default": true,
}
}
}
This will result in a check box in the dynamically generated GUI, with the initial check state shown in default.