display_input_modal()
  • 1 Minute to read

display_input_modal()


Article summary

This function displays an input modal component.

The input modal component provides a dialog screen asking from the user to enter some information. The component can be used for example to ask the user ‘what is the robot name?’

Reference

Screen Shot 2022-07-07 at 11.12.39 AM.png

Explore more about this component here

Arguments

ArgumentsTypeDefault Value
titlestringTitle of the modal (mandatory)
title_sizeenumUI_TITLE_SIZE.MEDIUMSize of the title
subtitlestringSubtitle of the modal (optional)
submit_textstring"Yes"Submit text button
cancel_textstring"No"Cancel text button
placeholderstringText that will appear in the input field before the user enter some data
input_typeenumUI_INPUT_TYPE.TEXTEnum to define the type of the input allowed, check UI_INPUT_TYPE
show_back_buttonboolFalseShow a button to go back
back_button_textstring"Back"Text of the back button
button_sizeint1Button size (1 = SMALL, 2 = MEDIUM, 3 = LARGE)
languageslistNoneList of languages to be displayed on the screen (optional)
chosen_languagestrNoneIf list given, string representing chosen language
themeenumUI_THEME_TYPE.DARKEnum to define the theme of the screen, check UI_THEME_TYPE
custom_styledictNoneDictionary containing custom styles for the modal (optional)
waitboolTrueBool indicating to wait for user response (optional)
callbackcallableNoneCallable function to handle the response (optional)

See the complete list of general enumerations.

Return

Dictionary that contains the action performed by the user and the value he entered.
The action can be: canceled/confirmed/closed.
Ex: {"action": "confirmed", "value": "4"}

Exceptions

  • RayaUIMissingValue
  • RayaNeedCallback

See the complete list of ui exceptions and the complete list of general exceptions.

Callback Arguments

callback

ArgumentTypeDescription
datadictDict containing the result of the action

Example

...

class RayaApplication(RayaApplicationBase):

    async def setup(self):
        self.UI = await self.enable_controller('ui')
        ....
        
    async def loop(self):
     ....
        response = await self.UI.display_input_modal(title="How many boxes?")
        self.log.info(response)
      ...
      
    async def finish(self):
      ...

...
'''
{"action": "confirmed", "value": "4"}
'''

Was this article helpful?