|
The SPB module is an
external python module. To be available in python script the SPB
module must be imported- see example.
The SPB module provides access to the Scorpion configuration file
- scorpion.spb. The Scorpion configuration file format is based on
xml. SPB stands for Structured Property Bag. In Scorpion spb is used
as a default extention for spbxml files.
The Spb class
The following methods are available in SPB module to create an
spb object:
- CreateSpb() - creates an emtpy spb object.
- CreateSpb(spbxml) - creates a spb object from an
spbxml document
- CreateSpb(filename) - creates a spb object from a
spbxml document on disk
| Property |
Access |
Type |
Description |
| root |
R/W |
string |
the spb root - may be used to specify
sections/entries relative to root instead of absolute
path |
| delimiter |
R |
string |
the spb delimiter (normally dot, '.') |
| xml |
R/W |
string |
the spb as a SPB xml document |
Note: All methods is relative to the root attribute, but the
named section or entry may also contain sub-sections.
| Method |
Returns |
Description |
| isSection(path) |
0/1 |
returns true/false wether the sectionexists or
not |
| addSection(path) |
0/1 |
creates section. Returns true if created,
false if creation failed or already exists |
| deleteSection(path) |
0/1 |
deletes section. returns true if exists, else
false |
| isEntry(entry) |
0/1 |
returns true if the entry exists |
| getEntryType(entry) |
value |
returns the datatype as text of entry if existing else None
Supported types are:
- 'bool'
- 'int',
- 'float',
- 'text',
- 'bin'
|
| deleteEntry(entry) |
0/1 |
delete entry, returns true if existing and
deleted |
| getBool(entry) |
value |
returns spb value if entry exists as 0 or 1, else None |
| getInt(entry) |
value |
returns spb value if entry exists as integer
type, else None |
| getFloat(entry) |
value |
returns spb value if entry exists as float type,
else None |
| getText(entry) |
value |
returns spb value if entry exists as text type,
else None |
| setBool(entry,value) |
0/1 |
returns true if success, false if entry exists
of another type |
| setInt(entry,value) |
0/1 |
returns true if success, false if entry exists
of another type |
| setFloat(entry,value) |
0/1 |
returns true if success, false if entry exists
of another type |
| setText(entry,value) |
0/1 |
returns true if success, false if entry exists
of another type |
| getSections(path) |
tuple |
returns a tuple of section names in given path |
| getEntrys(path) |
tuple |
returns a tuple of entrys in given path |
| load(filename) |
0/1 |
loads a spb xml document from disk |
| save(filename) |
0/1 |
saves the spb xml to disk |
Note: The tool configuration can be browsed using the
SPBEditor utility. The SPBEditor is activated from
Service.General
Example 1 - Change tool
configuration using the SPB
import SPB
tool=GetTool('FindReference')
spb=SPB.CreateSpb(tool.config)
spb.setFloat('ROI.x',10)
spb.setFloat('ROI.y',15)
tool.config=spb.xml
Example 2 - Save a tool to a disk file
import SPB
tool=GetTool('FindReference')
spb=SPB.CreateSpb(tool.config)
spb.save('tool.spb')
Example 3 - Load a tool to a disk file
into a tool in the toolbox
import SPB
tool=GetTool('FindReference')
spb=SPB.CreateSpb()
spb.load('tool.spb')
tool.config = spb.xml
|