class pygame_menu.widgets.TextInput(label='', textinput_id='', input_type='__pygame_menu_input_text__', input_underline='', copy_paste_enable=True, cursor_color=(0, 0, 0), cursor_selection_color=(30, 30, 30), cursor_selection_enable=True, history=50, maxchar=0, maxwidth=0, maxwidth_dynamically_update=True, onchange=None, onreturn=None, password=False, password_char='*', repeat_keys_initial_ms=450, repeat_keys_interval_ms=80, repeat_mouse_interval_ms=100, tab_size=4, text_ellipsis='...', valid_chars=None, *args, **kwargs)[source]

Bases: pygame_menu.widgets.core.widget.Widget

Text input widget.

  • label (str) – Input label text
  • textinput_id (str) – ID of the text input
  • input_type (str) – Type of data
  • input_underline (str) – Character drawn under the input
  • cursor_color (tuple) – Color of cursor
  • cursor_selection_color (tuple) – Selection box color
  • cursor_selection_enable (bool) – Enables selection of text
  • copy_paste_enable (bool) – Enables copy, paste and cut
  • history (int) – Maximum number of editions stored
  • maxchar (int) – Maximum length of input
  • maxwidth (int) – Maximum size of the text to be displayed (overflow), if 0 this feature is disabled
  • maxwidth_dynamically_update (bool) – Dynamically update maxwidth depending on char size
  • onchange (callable, None) – Callback when changing the selector
  • onreturn (callable, None) – Callback when pressing return button
  • password (bool) – Input string is displayed as a password
  • password_char (str) – Character used by password type
  • repeat_keys_initial_ms (int, float) – Time in ms before keys are repeated when held
  • repeat_keys_interval_ms (int, float) – Interval between key press repetition when held
  • repeat_mouse_interval_ms (int, float) – Interval between mouse events when held
  • tab_size (int) – Tab whitespace characters
  • text_ellipsis (str) – Ellipsis text when overflow occurs (input length exceeds maxwidth)
  • valid_chars (list) – List of chars that are valid, None if all chars are valid
  • kwargs (any) – Optional keyword-arguments for callbacks

Clear the current text.


Draw the widget shape.

Parameters:surface (pygame.Surface) – Surface to draw

Returns the value of the text.

Returns:Text inside the widget
Return type:str

Set the value of the text.

Parameters:text (str, int, float) – New text of the widget

Update internal variable according to the given events list and fire the callbacks.

Parameters:events (list[pygame.event.Event]) – List of pygame events
Returns:True if updated
Return type:bool