ColorInput

class pygame_menu.widgets.ColorInput(label='', colorinput_id='', color_type='rgb', input_separator=', ', input_underline='_', cursor_color=(0, 0, 0), onchange=None, onreturn=None, prev_size=3, repeat_keys_initial_ms=450, repeat_keys_interval_ms=80, repeat_mouse_interval_ms=100, *args, **kwargs)[source]

Bases: pygame_menu.widgets.widget.textinput.TextInput

Color input widget.

Parameters:
  • label (str) – Input label text
  • colorinput_id (str) – ID of the text input
  • color_type (str) – Type of color input (rgb, hex)
  • input_separator (str) – Divisor between RGB channels
  • input_underline (str) – Character drawn under each number input
  • cursor_color (tuple) – Color of cursor
  • onchange (callable, None) – Callback when changing the selector
  • onreturn (callable, None) – Callback when pressing return button
  • prev_size (int, float) – Width of the previsualization box in terms of the height of the widget
  • 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
  • kwargs (any) – Optional keyword-arguments for callbacks
clear()[source]

Clear the current text.

Returns:None
draw(surface)[source]

Draw the widget shape.

Parameters:surface (pygame.Surface) – Surface to draw
Returns:None
get_value()[source]

Return the color value as a tuple or red blue and green channels. If the data is invalid the widget returns (-1,-1,-1).

Returns:Color tuple as (R,G,B)
Return type:tuple
set_value(rgb_tuple)[source]

Set the value of the text.

Parameters:text (str, int, float) – New text of the widget
Returns:None
update(events)[source]

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