10.3. Algorithms and Widgets#
itom algorithm plugins can contain two different types of code:
Most algorithm plugins consist of one or multiple algorithms (also denoted as filters) that can both be called from Python scripts as well as from any other itom plugin.
To call an algorithm with the exemplary name
myAlgo
from Python, use one of the two following possibilities:call
itom.filter("myAlgo", *args, **kwds)
for a generic call of any algorithm.use the wrapper method
myAlgo
from the submodulealgorithms
ofitom
:import itom # args and kwds are the mandatory (or optional) parameters of the # specific algorithm 'myAlgo'. The returned value is either None, # a single value or a tuple of values. result = itom.algorithms.myAlgo(*args, **kwds)
This 2nd possibility is available from itom 5.0.0 on and allows using auto completion and calltips with a context sensitive help for the specific algorithm. The set of available methods in the
itom.algorithms
submodule depends on the loaded algorithm plugins of your itom application.
Algorithm plugins can also contain custom user interfaces. The create and show such an user interface, call the method
createNewPluginWidget()
orcreateNewPluginWidget2()
. To get an online help, usewidgetHelp()
.
For more information, see also Getting started with algorithm plugins (denoted as filters) or in the demo file demoGaussianSpotCentroidDetection.py.
- itom.filter(name, *args, _observer=None, **kwds) Any #
Invokes a filter (or algorithm) function from an algorithm-plugin.
This function is used to invoke itom filter-functions or algorithms, declared within itom-algorithm plugins. The parameters (arguments) depends on the specific filter function. Call
filterHelp()
to get a list of available filter functions.Pass all mandatory or optional arguments of the filter as positional or keyword-based parameters. Some filters, that implement the additional observer interface, can accept another
progressObserver
object, that allows monitoring the progress of the filter and / or interrupting the execution. If such an observer is given, you have to pass it as keyword-based argument_observer
!.During the execution of the filter, the python GIL (general interpreter lock) is released (e.g. for further asynchronous processes).
Instead of this generic function to call any itom algorithm from an algorithm plugin, these algorithms are also available via the direct algorithm wrapper methods in the submodule
itom.algorithms
(see Algorithms and Widgets).- Parameters:
- name
str
The name of the filter
- *args
Any
positional arguments for the specific filter-method
- _observer
progressObserver
,optional
if the called filter implements the extended interface with progress and status information, an optional
progressObserver
object can be given (only as keyword-based parameter) which is then used as observer for the current progress of the filter execution. It is then also possible to interrupt the execution earlier (depending on the implementation of the filter). The observer object is reset before passed to the called filter function (using the slotreset()
).- **kwds
Any
keyword-based arguments for the specific filter-method. The argument name
_observer
is reserved for special use.
- name
- Returns:
- out
obj
The returned values depend on the definition of each filter. In general it is a tuple of all output parameters that are defined by the filter function.
- out
See also
- itom.filterHelp(filterName='', dictionary=0, furtherInfos=0) dict | None #
Print outs an online help for the given filter(s) or return help information as dictionary.
This method prints information about one specific filter (algorithm) or a list of filters to the console output. If one specific filter, defined in an algorithm plugin, can be found that case-sensitively fits the given
filterName
, its full documentation is printed or returned. Else, a list of filters is printed whose name contains the givenfilterName
.- Parameters:
- filterName
str
,optional
is the fullname or a part of any filter name which should be displayed. If
filterName
is empty or no filter matchesfilterName
(case sensitive) a list with all suitable filters is given.- dictionary
int
,optional
if
1
, a dictionary with all relevant information about the documentation of this filter is returned as dictionary and nothing is printed to the command line (default: 0).- furtherInfos
int
,optional
Usually, filters or algorithms whose name only contains the given
filterName
are only listed at the end of the information text. If this parameter is set to1
(default:0
), the full information for all these filters is printed as well.
- filterName
- Returns:
- info
dict
This dictionary is only returned, if
dictionary
is set to1
. ElseNone
is returned. The dictionary contains relevant information about the desiredfilterName
.
- info
- itom.widgetHelp(widgetName='', dictionary=0, furtherInfos=0) dict | None #
Print outs an online help for the given widget(s) or return help information as dictionary.
This method prints information about one specific widget (defined in an algorithm plugin) or a list of widgets to the console output. If one specific widget can be found that case-sensitively fits the given
widgetName
, its full documentation is printed or returned. Else, a list of widgets is printed whose name contains the givenwidgetName
.- Parameters:
- widgetName
str
,optional
is the fullname or a part of any widget name which should be displayed. If
widgetName
is empty or no widget matcheswidgetName
(case sensitive) a list with all suitable widgets is given.- dictionary
int
,optional
if
1
, a dictionary with all relevant information about the documentation of this widget is returned as dictionary and nothing is printed to the command line (default: 0).- furtherInfos
int
,optional
Usually, widgets whose name only contains the given
widgetName
are only listed at the end of the information text. If this parameter is set to1
(default:0
), the full information for all these widgets is printed as well.
- widgetName
- Returns:
- info
dict
This dictionary is only returned, if
dictionary
is set to1
. ElseNone
is returned. The dictionary contains relevant information about the desiredwidgetName
.
- info