viktor.parametrization
Interaction
- class viktor.parametrization.Interaction(view, selection=None)¶
Bases:
ABC
- Parameters
view (
str
) – method name of the view to be interacted with.selection (
Sequence
[str
]) – only features/objects within selected interaction groups can be interacted with. Interaction groups can be created on the view result (e.g.MapResult
) using ‘interaction_groups’. None, to enable interaction with all features/objects with ‘identifier’ assigned, ignoring interaction groups (default: None).
MapSelectInteraction
- class viktor.parametrization.MapSelectInteraction(view, *, selection=None, min_select=1, max_select=None)¶
Bases:
Interaction
New in v13.2.0Interaction for the selection of feature(s) in a map view.
See
Interaction
for parameters.Additional parameters:
- Parameters
min_select (
int
) – minimum number of features a user must select (>=1).max_select (
int
) – maximum number of features a user may select. None for no limit (default: None).
Example:
button = ActionButton(..., interaction=MapSelectInteraction('my_map_view', selection=['points']))
DownloadButton
- class viktor.parametrization.DownloadButton(ui_name, method, longpoll=False, *, visible=True, always_available=False, flex=None, description=None, interaction=None)¶
Bases:
_ActionButton
Action button which can be pressed to download a result to a file.
Example usage:
# in parametrization: download_btn = DownloadButton("Download file", "get_download_result", longpoll=True) # in controller: def get_download_result(self, params, **kwargs): return DownloadResult(file_content='file_content', file_name='some_file.txt')
- Parameters
ui_name (
str
) – Name which is visible in the VIKTOR user interface.method (
str
) – Name of the download method that is defined in the controllerlongpoll (
bool
) – Set this option to True if the process that is invoked by the action button cannot be completed within the timeout limit.visible (
Union
[bool
,BoolOperator
,Lookup
,FunctionLookup
,DynamicArrayConstraint
,RowLookup
,Callable
]) – Visibility of the button. A Constraint can be used when the visibility depends on other input fields.always_available (
bool
) – deprecatedflex (
int
) – The width of the field can be altered via this argument. value between 0 and 100 (default=33).description (
str
) – Show more information to the user through a tooltip on hover (max. 200 characters).interaction (
Interaction
) – Enable view interaction through this buttonNew in v13.2.0
ActionButton
- class viktor.parametrization.ActionButton(ui_name, method, longpoll=True, *, visible=True, always_available=False, flex=None, description=None, interaction=None)¶
Bases:
_ActionButton
Action button which can be pressed to perform a (heavy) calculation without returning a result.
Example usage:
# in parametrization: calculation_btn = ActionButton("Analysis", "calculation", longpoll=True) # in controller: def calculation(self, params, **kwargs): # perform calculation, no return necessary
- Parameters
ui_name (
str
) – Name which is visible in the VIKTOR user interface.method (
str
) – Name of the download method that is defined in the controllerlongpoll (
bool
) – Set this option to True if the process that is invoked by the action button cannot be completed within the timeout limit.visible (
Union
[bool
,BoolOperator
,Lookup
,FunctionLookup
,DynamicArrayConstraint
,RowLookup
,Callable
]) – Visibility of the button. A Constraint can be used when the visibility depends on other input fields.always_available (
bool
) – deprecatedflex (
int
) – The width of the field can be altered via this argument. value between 0 and 100 (default=33).description (
str
) – Show more information to the user through a tooltip on hover (max. 200 characters).interaction (
Interaction
) – Enable view interaction through this buttonNew in v13.2.0
AnalyseButton
- viktor.parametrization.AnalyseButton¶
alias of
ActionButton
OptimizationButton
- class viktor.parametrization.OptimizationButton(ui_name, method, longpoll=True, *, visible=True, always_available=False, flex=None, description=None, interaction=None)¶
Bases:
_ActionButton
Action button which can be pressed to perform an optimization routine.
Example usage:
# in parametrization: optimize_btn = OptimizationButton("Optimization", "get_optimal_result", longpoll=True) # in controller: def get_optimal_result(self, params, **kwargs): # specific optimization routine ... return OptimizationResult(results)
- Parameters
ui_name (
str
) – Name which is visible in the VIKTOR user interface.method (
str
) – Name of the download method that is defined in the controllerlongpoll (
bool
) – Set this option to True if the process that is invoked by the action button cannot be completed within the timeout limit.visible (
Union
[bool
,BoolOperator
,Lookup
,FunctionLookup
,DynamicArrayConstraint
,RowLookup
,Callable
]) – Visibility of the button. A Constraint can be used when the visibility depends on other input fields.always_available (
bool
) – deprecatedflex (
int
) – The width of the field can be altered via this argument. value between 0 and 100 (default=33).description (
str
) – Show more information to the user through a tooltip on hover (max. 200 characters).interaction (
Interaction
) – Enable view interaction through this buttonNew in v13.2.0
OptimiseButton
- viktor.parametrization.OptimiseButton¶
alias of
OptimizationButton
SetParamsButton
- class viktor.parametrization.SetParamsButton(ui_name, method, longpoll=True, *, visible=True, always_available=False, flex=None, description=None, interaction=None)¶
Bases:
_ActionButton
Action button which can be pressed to perform an analysis and override current input fields.
Example usage:
# in parametrization: set_params_btn = SetParamsButton("Set params", "set_param_a", longpoll=True) # in controller: def set_param_a(self, params, **kwargs): # get updated input parameters ... return SetParamsResult(updated_parameter_set)
- Parameters
ui_name (
str
) – Name which is visible in the VIKTOR user interface.method (
str
) – Name of the download method that is defined in the controllerlongpoll (
bool
) – Set this option to True if the process that is invoked by the action button cannot be completed within the timeout limit.visible (
Union
[bool
,BoolOperator
,Lookup
,FunctionLookup
,DynamicArrayConstraint
,RowLookup
,Callable
]) – Visibility of the button. A Constraint can be used when the visibility depends on other input fields.always_available (
bool
) – deprecatedflex (
int
) – The width of the field can be altered via this argument. value between 0 and 100 (default=33).description (
str
) – Show more information to the user through a tooltip on hover (max. 200 characters).interaction (
Interaction
) – Enable view interaction through this buttonNew in v13.2.0
Lookup
- class viktor.parametrization.Lookup(target)¶
-
Can be used to lookup the value of an input field. This can be used to set visibility of a field and to set a minimum and / or maximum boundary on a number field.
Example usage on visibility:
field_1 = BooleanField('Field 1') field_2 = NumberField('Field 2', visible=Lookup('field_1'))
Example usage on min / max:
field_1 = NumberField('Field 1') field_2 = NumberField('Field 2', min=Lookup('field_1'))
- Parameters
target (
str
) – Name of input field.
FunctionLookup
- class viktor.parametrization.FunctionLookup(func, *func_args, **kwargs)¶
-
Defines a lookup constraint where the output value is any function of several input fields.
Example usages:
def multiply(a, b=10): return a * b field_1 = NumberField('Field 1') field_2 = NumberField('Field 2')
Standard usage with two field arguments:
field_3 = NumberField('Field 3', min=FunctionLookup(multiply, Lookup('field_1'), Lookup('field_2')))
Using the default value of argument b:
field_4 = NumberField('Field 4', min=FunctionLookup(multiply, Lookup('field_1')))
Using a constant instead of a field for argument a:
field_5 = NumberField('Field 5', min=FunctionLookup(multiply, 8, Lookup('field_2')))
- Parameters
func (
Callable
) – Python function or lambda expression. The function can have arguments with default values.func_args (
Any
) – Arguments that are provided to the function. Arguments of type Lookup / BoolOperator are evaluated first (e.g. to refer to the value of a Field in the editor, a Lookup can be used).
RowLookup
- class viktor.parametrization.RowLookup(target)¶
-
Can be used to lookup the value of an input field within the same row of the dynamic array. This can be used to set the visibility of a field and a minimum and / or maximum boundary on a number field.
Example usage:
array = DynamicArray('Array') array.field_1 = NumberField('Field 1') array.field_2 = NumberField('Field 2', min=RowLookup('field_1'))
For more complex constructions, it is advised to use a callback function.
- Parameters
target (
str
) – Name of input field within the dynamic array.
BoolOperator
- class viktor.parametrization.BoolOperator¶
Bases:
ABC
Warning
Do not use this class directly in an application.
Base class for operators that can be used for field visibility and min/max. See the documentation of the subclasses for example implementations.
And
- class viktor.parametrization.And(*operands)¶
Bases:
BoolOperator
Can be used to evaluate multiple operands to be True.
field_1 = NumberField('Field 1') field_2 = BooleanField('Field 2') field_3 = NumberField('Field 3', visible=And(IsEqual(Lookup('field_1'), 5), Lookup('field_2')))
- Parameters
operands (
Union
[Lookup
,BoolOperator
,bool
]) – Operands to be evaluated.
Or
- class viktor.parametrization.Or(*operands)¶
Bases:
BoolOperator
Can be used to evaluate if at least one operand is True.
field_1 = NumberField('Field 1') field_2 = BooleanField('Field 2') field_3 = NumberField('Field 3', visible=Or(IsEqual(Lookup('field_1'), 5), Lookup('field_2')))
- Parameters
operands (
Union
[Lookup
,BoolOperator
,bool
]) – Operands to be evaluated.
Not
- class viktor.parametrization.Not(operand)¶
Bases:
BoolOperator
Can be used to evaluate an operand to be False.
field_1 = NumberField('Field 1') field_2 = NumberField('Field 2', visible=Not(IsEqual(Lookup('field_1'), 5)))
Note, above construction is the same as:
field_1 = NumberField('Field 1') field_2 = NumberField('Field 2', visible=IsNotEqual(Lookup('field_1'), 5))
- Parameters
operand (
Union
[Lookup
,BoolOperator
,bool
]) – Operand to be evaluated.