Textual input
For a more technical API reference, please see TextField
,
TextAreaField
, and Text
.
TextField - short texts
A TextField
is a simple textual input field.
import viktor as vkt
class Parametrization(vkt.Parametrization):
text = vkt.TextField('This is a TextField')
The user input can be obtained through the params argument and can have the following values:
str
: when user inputs a text (e.g. "some text")- empty string when empty
Expand to see all available arguments
In alphabetical order:
-
default: a default value will be prefilled
text = vkt.TextField('This is a TextField', default="John Doe")
-
description: add a tooltip with additional information
text = vkt.TextField('This is a TextField', description="This input represent the ...")
-
flex: the width of the field between 0 and 100 (default=33)
text = vkt.TextField('This is a TextField', flex=50)
-
name: defines the position of the parameter in the params
text = vkt.TextField('This is a TextField', name="t") # obtained using params.t
-
prefix: a prefix will be put in front of the ui name
text = vkt.TextField('This is a TextField', prefix="..")
-
suffix: a suffix will be placed behind the ui name
text = vkt.TextField('This is a TextField', suffix="..")
-
visible: can be used when the visibility depends on other input fields
text = vkt.TextField('This is a TextField', visible=vkt.Lookup("another_field"))
See 'Hide a field' for elaborate examples.
TextAreaField - longer texts
For lengthier inputs, the TextAreaField
can be used.
import viktor as vkt
class Parametrization(vkt.Parametrization):
text = vkt.TextAreaField('This is a TextAreaField')
The user input can be obtained through the params argument and can have the following values:
str
: when user inputs a text (e.g. "some very very very ... long text")- empty string when empty
Expand to see all available arguments
In alphabetical order:
-
default: a default value will be prefilled
text = vkt.TextAreaField('This is a TextAreaField', default="Multiple lines \n are possible")
-
description: add a tooltip with additional information
text = vkt.TextAreaField('This is a TextAreaField', description="This input represent the ...")
-
flex: the width of the field between 0 and 100 (default=100)
text = vkt.TextAreaField('This is a TextAreaField', flex=50)
-
name: defines the position of the parameter in the params
text = vkt.TextAreaField('This is a TextAreaField', name="t") # obtained using params.t
-
visible: can be used when the visibility depends on other input fields
text = vkt.TextAreaField('This is a TextAreaField', visible=vkt.Lookup("another_field"))
See 'Hide a field' for elaborate examples.
Text - static text blocks
For more information on how to add a static text to the parametrization, that cannot be modified by the user, see
Text
. There is no value associated with an Text
field within the
params
.