ScrollBar

class pygame_menu.widgets.ScrollBar(length, values_range, scrollbar_id='', orientation='__pygame_menu_orientation_horizontal__', slider_pad=0, slider_color=(200, 200, 200), page_ctrl_thick=20, page_ctrl_color=(235, 235, 235), onchange=None, onreturn=None, *args, **kwargs)[source]

Bases: pygame_menu.widgets.core.widget.Widget

A scroll bar include 3 separate controls: a slider, scroll arrows, and a page control:

  1. The slider provides a way to quickly go to any part of the document
  2. The scroll arrows are push buttons which can be used to accurately navigate to a particular place in a document.
  3. The page control is the area over which the slider is dragged (the scroll bar’s background). Clicking here moves the scroll bar towards the click by one “page”.

Warning

Arrows are not yet implemented

Parameters:
  • length (int) – Length of the page control
  • values_range (tuple, list) – Min and max values
  • scrollbar_id (str) – Bar identifier
  • orientation (str) – Bar orientation ORIENTATION_HORIZONTAL/ORIENTATION_VERTICAL
  • slider_pad (int, float) – Space between slider and page control
  • slider_color (tuple, list) – Color of the slider
  • page_ctrl_thick (int, float) – Page control thickness
  • page_ctrl_color (tuple, list) – Page control color
  • onchange (callable, None) – Callback when changing the selector
  • onreturn (callable, None) – Callback when pressing return button
draw(surface)[source]

Draw the widget shape.

Parameters:surface (pygame.Surface) – Surface to draw
Returns:None
get_maximum()[source]
Returns:Return the greatest acceptable value
Return type:int
get_minimum()[source]
Returns:Return the smallest acceptable value
Return type:int
get_orientation()[source]
Returns:Return the scroll bar orientation
Return type:str
get_page_step()[source]
Returns:Return amount that the value changes by when the user click on the page control surface
Return type:int
get_value()[source]

Return the value according to the slider position. :return: Position in pixels :rtype: int

set_length(value)[source]

Set the length of the page control area. :param value: Length of the area :type value: int, float :return: None

set_maximum(value)[source]

Set the greatest acceptable value. :param value: Maximum value :type value: int, float :return: None

set_minimum(value)[source]

Set the smallest acceptable value. :param value: Minimum value :type value: int, float :return: None

set_orientation(orientation)[source]

Set the scroll bar orientation to vertical or horizontal. :param orientation: Widget orientation, could be ORIENTATION_HORIZONTAL/ORIENTATION_VERTICAL :type orientation: str :return: None

set_page_step(value)[source]

Set the amount that the value changes by when the user click on the page control surface. The length of the slider is related to this value, and typically represents the proportion of the document area shown in a scrolling view. :param value: Page step :type value: int :return: None

set_value(value)[source]

Set the position of the scrollbar. :param value: Position :type value: int, float :return: 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