IfHelperV1

toloka.client.project.template_builder.helpers.IfHelperV1 | Source code

IfHelperV1(
self,
condition: Optional[BaseComponent] = None,
then: Optional[Any] = None,
*,
else_: Optional[Any] = None,
version: Optional[str] = '1.0.0'
)

The if then else operator.

For more information, see helper.if.

Parameters description

ParametersTypeDescription
conditionOptional[BaseComponent]

A condition to check.

thenOptional[Any]

A component that is returned if the condition is True.

else_Optional[Any]

A component that is returned if the condition is False.

Examples:

How to conditionally show a part of the interface.

import toloka.client.project.template_builder as tb
hidden_ui = tb.helpers.IfHelperV1(
condition=tb.conditions.EqualsConditionV1(tb.data.OutputData('show_me'), 'show'),
then=tb.view.ListViewV1([header, buttons, images]),
)

Last updated: August 28, 2023

Toloka-Kit
OverviewGetting API keyQuick start
Recipes
Reference
toloka.client
toloka.async_client
toloka.autoquality [autoquality]
toloka.metrics
toloka.streaming