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”.


Arrows are not yet implemented

  • 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 the widget shape.

Parameters:surface (pygame.Surface) – Surface to draw
Returns:Return the greatest acceptable value
Return type:int
Returns:Return the smallest acceptable value
Return type:int
Returns:Return the scroll bar orientation
Return type:str
Returns:Return amount that the value changes by when the user click on the page control surface
Return type:int

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


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


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


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


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


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