Skip to main content

Other fields

Select a color

New in v14.0.0

The ColorField enables a user to select a color from a color palette.

from viktor.parametrization import ViktorParametrization, ColorField

class Parametrization(ViktorParametrization):
color = ColorField('Pick a color')

The value is returned in the params as a Color object.

Select a date

The DateField enables a user to select a date on a calendar.

from viktor.parametrization import ViktorParametrization, DateField

class Parametrization(ViktorParametrization):
date = DateField('Pick a date')

The value is returned in the params as a object.

Toggle button

The BooleanField acts as a toggle button which can be either True or False:

from viktor.parametrization import ViktorParametrization, BooleanField

class Parametrization(ViktorParametrization):
is_true = BooleanField('False / True')

Generic JSON data

The purpose of the HiddenField is to store JSON-type data in the params, without showing this information to the user in the editor. For example, when doing upload file processing.

from viktor.parametrization import ViktorParametrization, HiddenField

class Parametrization(ViktorParametrization):
json_data = HiddenField('This is not visible')

Use the HiddenField with moderation. Prefer to store specific type of data on its corresponding field (e.g. number on a NumberField), if necessary with visible=False to hide if from the user. Also, prevent storing very large amounts of data if not necessary, as this might make your application slow and unstable!

Manual line break

For more information on how to add a manual line break to the parametrization, see LineBreak. There is no value associated with a LineBreak within the params.