ValueType
Variables can be defined and manipulated through ValueType and UIType. ValueType is useful to define and process the variables. For example,
Copy "quiz_status" : ValueType (
type = "str" ,
value = 'default' ,
),
Copy "quiz_idx" : ValueType (
type = "int" ,
value = "${min(quiz_idx + 1, len(words) - 1)}" ,
),
In the above example, we can use ${} to wrap an expression to update a variable called qui_idx.
the type of the ValueType can be
Copy [ "str" , "int" , "float" , "bool" , "list" , "dict" ]
Variables from user inputs are handled by UIType. We support the following UITypes
UIType
Dropdown
Copy "level" : Dropdown (
value = None ,
choices = [ "easy" , "medium" , "hard" ],
label = "Choose Level:"
),
to choose from some choices
Button
Copy "level" : Dropdown (
value = None ,
choices = [ "easy" , "medium" , "hard" ],
label = "Choose Level:"
),
often used as triggers, to submit a form or jump to next pages
Textbox
Copy "quiz_info" : Textbox (
value = '${f"{quiz_idx + 1} / {len(words)} words"}' ,
label = "Info"
),
display some information using plain-text
Image
Copy "image" : Image (
value = "${word2material[word_txt]['pic_path']}" ,
show_label = False ,
height = image_height,
width = image_height,
show_download_button = False ,
),
display an image, the size of the image can be manually controlled
Gallery
Copy 'word_images' : Gallery (
value = "${[word2material[word]['pic_path'] for word in [choice_0, choice_1, choice_2, choice_3]]}" ,
columns = 2 ,
height = 550 ,
show_label = False ,
),
display a group of images
Audio
Copy "audio_word" : Audio (
value = "${word2material[word_txt]['word_tts_audio_path']}" ,
label = "Word Pronunciation" ,
),
play a audio, the value need to be the path of the audio
DisplayDropdown
Copy "topic" : DisplayDropdown (
choices = "$ {topics} " ,
initial_choices = [ "" ],
interactive = True ,
label = "Choose Topic:" ,
),
used when the choices need to be dynamically updated
Last updated 11 months ago