Python PyWebIO | input() method

PyWebIO provides a set of imperative methods for obtaining user input and output on the browser, thereby converting it into a “rich text terminal,” and may be used to create simple web apps or browser-based GUI applications. PyWebIO is a Python library that allows you to build simple web applications without the knowledge of HTML and Javascript. We will dive deep into the input() function, examining how we may obtain more effective input from the user.


input(label='', type='', validate=None, placeholder=None, required=None,
readonly=None, datalist=None, help_text=None)
  • label: Label of the input field
  • type: Input type, currently supported types are: TEXT, NUMBER, FLOAT, PASSWORD, URL.


input(label="Hello", type=TEXT)
input(label="Hello", type=NUMBER)
input(label="Hello", type=FLOAT)
input(label="Hello", type=PASSWORD)
input(label="Hello", type=URL)
  • validate:

Function for validating input values. The validation function will be called if it is provided when the user completes the input field or submits the form.

As an argument, validate takes the input value. It returns None if the input value is valid. When the input value is invalid, an error message string is returned.

Sample Code:

# Validate Function
def check_age(age):
if age > 30:
return 'Too old'
elif age < 10:
return 'Too young'
# Taking input from the user
input('Input your age', type=NUMBER, validate=check_age)
  • placeholder: A suggestion to the user about what they can type in the input. When there is no value set, it will show in the input field.
input(label="Hello", placeholder="GeeksForGeeks")
  • required: If a value is necessary for the input to be submittable, the default value is False.
input(label="Hello", placeholder="GeeksForGeeks", required=True)
  • readonly: Whether the value is read-only (not editable)
input(label="Hello", placeholder="GeeksForGeeks", readonly=True)
  • datalist: For this input, a set of predetermined values to suggest to the user. Only applicable when type=TEXT.
input(label="Hello", datalist=["Hey", "Hello", "Hey1", "Hello1", "How", "Why"])
  • help_text: The input’s help text. The text will be shown in tiny font below the input area.
input(label="Hello", help_text="GeeksForGeeks")

I’m a passionate and innovative programmer that likes contributing to open source, writing articles, and implementing new ideas.