viktor.parametrization
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
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.
AutocompleteField
- class viktor.parametrization.AutocompleteField(ui_name, options, name=None, prefix=None, suffix=None, default=None, visible=True, flex=None, *, description=None)
Bases:
_SelectField
Similar to OptionField, except for two differences:
user can type to search for option
single option is not pre-selected
Example usage:
field = AutocompleteField('Available options', options=['Option 1', 'Option 2'], default='Option 1')
Or use an OptionListElement to obtain a value in the params which differs from the interface name:
_options = [OptionListElement('option_1', 'Option 1'), OptionListElement('option_2', 'Option 2')] field = AutocompleteField('Available options', options=_options, default='option_1')
See
Field
for parameters.Additional parameters:
- Parameters:
options (
Union
[List
[Union
[float
,str
,OptionListElement
]],Callable
]) – Options should be defined as a list of numbers, strings, or OptionListElement objects.
Data:
type of selected option: integer, float or string
None when nothing is selected
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.
BooleanField
ChildEntityManager
- class viktor.parametrization.ChildEntityManager(entity_type_name, *, visible=True)
Bases:
Field
New in v14.2.0Manager in which a user can create, inspect, and delete child entities of a specific type.
- Parameters:
entity_type_name (
str
) – User will only be able to manage entities of specified type.visible (
Union
[bool
,BoolOperator
,Lookup
,FunctionLookup
,DynamicArrayConstraint
,RowLookup
,Callable
]) – Can be used when the visibility depends on other input fields.
ChildEntityMultiSelectField
- class viktor.parametrization.ChildEntityMultiSelectField(ui_name, name=None, visible=True, flex=None, *, entity_type_names=None, description=None)
Bases:
_EntityMultiSelectField
Field to select zero or more child entities of given type(s). Up to 5000 entities may be visualized in the dropdown in the interface.
Data:
List[
Entity
]Empty list when nothing is selected
See
Field
for parameters.Additional parameters:
- Parameters:
entity_type_names (
List
[str
]) – User will only be able to select entities of types within this list. None = all entities.
ChildEntityOptionField
- class viktor.parametrization.ChildEntityOptionField(ui_name, name=None, visible=True, flex=None, *, entity_type_names=None, description=None)
Bases:
_EntityOptionField
Field to select a child entity of given type(s). Single option is not automatically pre-selected.
Data:
None when nothing is selected
See
Field
for parameters.Additional parameters:
- Parameters:
entity_type_names (
List
[str
]) – User will only be able to select entities of types within this list. None = all entities.
ColorField
DateField
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
DynamicArray
- class viktor.parametrization.DynamicArray(ui_name, min=None, max=None, copylast=None, visible=True, default=None, *, description=None, row_label=None)
Bases:
_AttrGroup
Fields can be added under a dynamic array.
Currently, it is not possible to add:
Example usage:
layers = DynamicArray("layers") layers.depth = NumberField("depth") layers.material = OptionField("material", options=my_options)
- Parameters:
ui_name (
str
) – This string is visible in the VIKTOR user interface.min (
Union
[int
,Lookup
,FunctionLookup
,Callable
]) – Minimum number of rows in the array.max (
Union
[int
,Lookup
,FunctionLookup
,Callable
]) – Maximum number of rows in the array.copylast (
bool
) – Copy the last row when clicking the + button. Takes precedence over field defaults.visible (
Union
[bool
,BoolOperator
,Lookup
,FunctionLookup
,Callable
]) – Can be used when the visibility depends on other input fields.default (
List
[dict
]) – Default values of complete array. Filled before user interaction.description (
str
) – Show more information to the user through a tooltip on hover (max. 200 characters).row_label (
str
) – Label to be shown at each row. The row number is appended to the label (max. 30 characters).
The default values of the DynamicArray are filled when the editor is entered for the first time (just like the other fields). The fields underneath the dynamic array can also have default values. These are filled when the user adds a new row. If copylast is True, the last values are copied, and the Field defaults are ignored.
array = DynamicArray('Dyn Array', default=[{'a': 1, 'b': 'hello'}, {'a': 2, 'b': 'there'}]) array.a = NumberField('A', default=99) array.b = TextField('B', default='foo')
When first entering the editor:
A
B
1
hello
2
there
When adding a new row:
A
B
1
hello
2
there
99
foo
When using copylast:
array = DynamicArray('Dyn Array', copylast=True, default=[{'a': 1, 'b': 'hello'}]) array.a = NumberField('A', default=99) array.b = TextField('B', default='foo')
When first entering the editor:
A
B
1
hello
When adding a new row:
A
B
1
hello
1
hello
Data:
list of dictionaries: e.g. [{‘a’: 1, ‘b’: ‘1’}, {‘a’: 2, ‘b’: ‘2’}]
empty list if there are no ‘rows’
when fields are empty, the corresponding empty values are used (see documentation of specific field)
DynamicArrayConstraint
- class viktor.parametrization.DynamicArrayConstraint(dynamic_array_name, operand)
-
This constraint facilitates usage of other constraints within a dynamic array row.
Warning
The DynamicArrayConstraint can currently only be used for the visibility of DynamicArray components.
Example usage:
_show_y = DynamicArrayConstraint('array_name', IsTrue(Lookup('$row.param_x'))) array = DynamicArray('My array') array.param_x = BooleanField('X') array.param_y = NumberField('Y', visible=_show_y)
- Parameters:
dynamic_array_name (
str
) – name of the dynamic array on which the constraint should be applied.operand (
Union
[Lookup
,BoolOperator
,FunctionLookup
]) – The inputs of the operand have to be altered to access the correct row within the dynamic array. The input for a target field becomes ‘$row.{field_name}’.
EntityMultiSelectField
- class viktor.parametrization.EntityMultiSelectField(ui_name, entity_type_names, *, name=None, visible=True, flex=None, description=None)
Bases:
_EntityMultiField
Field to select zero or more entities of given type(s).
See
Field
for parameters.Additional parameters:
- Parameters:
entity_type_names (
List
[str
]) – User will only be able to select entities of types within this list.
Data:
List[
Entity
]Empty list when nothing is selected
EntityOptionField
- class viktor.parametrization.EntityOptionField(ui_name, entity_type_names, *, name=None, visible=True, flex=None, description=None)
Bases:
_EntitySelectField
Field to select any entity of given type(s).
Single option is not automatically pre-selected.
See
Field
for parameters.Additional parameters:
- Parameters:
entity_type_names (
List
[str
]) – User will only be able to select entities of type(s) within this list.
Data:
None when nothing is selected
Field
- class viktor.parametrization.Field(*, ui_name, name=None, prefix=None, suffix=None, default=None, flex=None, visible=True, description=None)
Bases:
ABC
- Parameters:
ui_name (
str
) – This string is visible in the VIKTOR user interface.name (
str
) – The position of the parameter in the database can be specified in this argument.prefix (
str
) – A prefix will be put in front of the ui_name to provide info such as a dollar sign. Note that this function does not yet work for input fields.suffix (
str
) – A suffix will be put behind the ui_name to provide additional information such as units.default (
Any
) – The value or string that is specified here is filled in as a default input.flex (
int
) – The width of the field can be altered via this argument. value between 0 and 100 (default=33).visible (
Union
[bool
,BoolOperator
,Lookup
,FunctionLookup
,DynamicArrayConstraint
,RowLookup
,Callable
]) – Can be used when the visibility depends on other input fields.description (
str
) – Show more information to the user through a tooltip on hover (max. 200 characters).
FileField
- class viktor.parametrization.FileField(ui_name, file_types=None, *, max_size=None, name=None, visible=True, flex=None, description=None)
Bases:
_FileField
FileField can be used to let the user upload a file.
Data:
None when nothing is uploaded
See
Field
for parameters.Additional parameters:
- Parameters:
file_types (
Sequence
[str
]) – Optional restriction on file type(s) (e.g. [‘.png’, ‘.jpg’, ‘.jpeg’]) (case-insensitive).max_size (
int
) – Optional restriction on file size in bytes (e.g. 10_000_000 = 10 MB).
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).
GeoPointField
GeoPolygonField
GeoPolylineField
GeometryMultiSelectField
- class viktor.parametrization.GeometryMultiSelectField(ui_name, *, name=None, default=None, visible=True, flex=None, description=None, view=None, min_select=1, max_select=None)
Bases:
_GeometryField
New in v14.10.0Warning
The Geometry Selection fields are currently in BETA, which means we reserve the right to make breaking changes without providing an upgrade strategy.
GeometryMultiSelectField can be used to let the user select multiple geometry objects from a View.
Data:
List[str]
Empty list when nothing is selected
See
Field
for parameters.Additional parameters:
- Parameters:
view (
str
) – View method to which the field is connected (default: first GeometryView / IFCView).min_select (
int
) – Minimum amount of objects the user needs to select.max_select (
int
) – Maximum amount of objects the user is allowed to select.
GeometrySelectField
- class viktor.parametrization.GeometrySelectField(ui_name, *, name=None, default=None, visible=True, flex=None, description=None, view=None)
Bases:
_GeometryField
New in v14.10.0Warning
The Geometry Selection fields are currently in BETA, which means we reserve the right to make breaking changes without providing an upgrade strategy.
GeometrySelectField can be used to let the user select a geometry object from a View.
Data:
str
None when nothing is selected
See
Field
for parameters.Additional parameters:
- Parameters:
view (
str
) – View method to which the field is connected (default: first GeometryView / IFCView).
HiddenField
- class viktor.parametrization.HiddenField(ui_name, name=None)
-
The purpose of a HiddenField is to store data in the parametrization, without the necessity to show this information in the editor.
Warning
Do NOT store tremendous amounts of data when it is not necessary, as this will make your application slow and perhaps unstable!
- Parameters:
ui_name (
str
) – User-defined name of the field.name (
str
) – The position of the parameter in the database can be specified in this argument.
Image
- class viktor.parametrization.Image(path, *, align='center', caption=None, flex=100, max_width=None, visible=True)
Bases:
Field
New in v14.3.0Field that can be used to display a static image.
- Parameters:
path (
str
) – Path to the image relative to the assets directory, note that path traversal is not allowed.align (
Literal
['left'
,'center'
,'right'
]) – Image alignment (“left” | “center” | “right”).caption (
str
) – Image caption (max. 200 characters).flex (
int
) – Width of the image as percentage of the parametrization component.max_width (
int
) – A maximum width (pixels) can be set to ensure an image does not end up pixelated.visible (
Union
[bool
,BoolOperator
,Lookup
,FunctionLookup
,DynamicArrayConstraint
,RowLookup
,Callable
]) – Can be used when the visibility depends on other input fields.
IntegerField
- class viktor.parametrization.IntegerField(ui_name, name=None, prefix=None, *, suffix=None, default=None, step=None, min=None, max=None, visible=True, flex=None, description=None)
Bases:
NumberField
See
NumberField
for parametersAdditional parameters: -
Data:
integer, when filled
None, when empty
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).
IsEqual
- class viktor.parametrization.IsEqual(operand1, operand2)
Bases:
BoolOperator
Can be used to evaluate two operands to be equal.
field_1 = NumberField('Field 1') field_2 = NumberField('Field 2', visible=IsEqual(Lookup('field_1'), 5))
- Parameters:
operand1 (
Union
[Lookup
,BoolOperator
,Any
]) – First operand to be evaluated.operand2 (
Union
[Lookup
,BoolOperator
,Any
]) – Second operand to be evaluated.
IsFalse
- class viktor.parametrization.IsFalse(operand)
Bases:
IsEqual
Can be used to evaluate an operand to be False.
field_1 = NumberField('Field 1') field_2 = NumberField('Field 2', visible=IsFalse(Lookup('field_1')))
- Parameters:
operand (
Union
[Lookup
,BoolOperator
,Any
]) – Operand to be evaluated.
IsNotEqual
- class viktor.parametrization.IsNotEqual(operand1, operand2)
Bases:
IsEqual
Can be used to evaluate two operands to be NOT equal.
field_1 = NumberField('Field 1') field_2 = NumberField('Field 2', visible=IsNotEqual(Lookup('field_1'), 5))
- Parameters:
operand1 (
Union
[Lookup
,BoolOperator
,Any
]) – First operand to be evaluated.operand2 (
Union
[Lookup
,BoolOperator
,Any
]) – Second operand to be evaluated.
IsNotNone
- class viktor.parametrization.IsNotNone(operand)
Bases:
IsNotEqual
Can be used to evaluate an operand to be NOT None.
field_1 = NumberField('Field 1') field_2 = NumberField('Field 2', visible=IsNotNone(Lookup('field_1')))
- Parameters:
operand (
Union
[Lookup
,BoolOperator
,Any
]) – Operand to be evaluated.
IsTrue
- class viktor.parametrization.IsTrue(operand)
Bases:
IsEqual
Can be used to evaluate an operand to be True.
field_1 = NumberField('Field 1') field_2 = NumberField('Field 2', visible=IsTrue(Lookup('field_1')))
- Parameters:
operand (
Union
[Lookup
,BoolOperator
,Any
]) – Operand to be evaluated.
LineBreak
- class viktor.parametrization.LineBreak
-
Linebreaks can be used to force input fields to be placed in the next row to obtain a cleaner looking editor.
Example usage:
field_1 = NumberField() new_line = LineBreak() field_2 = NumberField()