ScrollBar¶
Bases:
pygame_menu.widgets.core.widget.Widget
A scroll bar include 3 separate controls: a slider, scroll arrows, and a page control:
- The slider provides a way to quickly go to any part of the document
- The scroll arrows are push buttons which can be used to accurately navigate to a particular place in a document.
- 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
Run
on_return
callback when return event. A callback function receives the following arguments:callback_func( value, *args, *widget._args, **widget._kwargs )
- with:
value
(if something is returned byget_value()
)args
given to this methodargs
of the widgetkwargs
of the widget
Parameters: args – Extra arguments passed to the callback Returns: None
Run
on_change
callback after change event is triggered. A callback function receives the following arguments:callback_func( value, *args, *widget._args, **widget._kwargs )
- with:
value
(if something is returned byget_value()
)args
given to this methodargs
of the widgetkwargs
of the widget
Parameters: args – Extra arguments passed to the callback Returns: None
Draw the widget shape.
Parameters: surface ( pygame.Surface
) – Surface to drawReturns: None
Draw selection effect on widget.
Parameters: surface ( pygame.Surface
) – Surface to drawReturns: None
Returns widget alignment.
Returns: Widget align, see locals Return type: str
Get attribute value.
Parameters: - key (str) – Key of the attribute
- default (Any) – Value if does not exists
Returns: Attribute data
Return type: Any
Return a dict with the information of the widget font.
Returns: Dict, keys: size (int), name (str), color (tuple), selected_color (tuple), antialias (bool) Return type: dict
Returns the widget ID.
Returns: ID Return type: str
Returns: Widget margin Return type: tuple
Returns: Return the greatest acceptable value Return type: int
Return menu reference (if exists).
Returns: Menu reference Return type: pygame_menu.Menu
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 Rect object, this forces the widget rendering
Returns: Widget rect Return type: pygame.Rect
Return time the widget has been selected in miliseconds. If the widget is not currently selected, return 0.
Returns: Time in ms Return type: float
Returns: Selection effect Return type: pygame_menu.widgets.core.Selection
Return the widget title.
Returns: Widget title Return type: str
Return the value according to the slider position.
Returns: Position in pixels Return type: int
Set the alignment of the widget.
Parameters: align (str) – Widget align, see locals Returns: None
Set widget attribute.
Parameters: - key (str) – Key of the attribute
- value (Any) – Value of the attribute
Returns: None
Set widget background color.
Parameters: - color (tuple, list,
pygame_menu.baseimage.BaseImage
, None) – Widget background color - inflate (tuple, list) – Inflate background in x,y
Returns: None
- color (tuple, list,
Enable interfaces to control the widget.
Parameters: Returns: None
Set the text font.
Parameters: - font (str, list) – Name or list of names for font (see pygame.font.match_font for precise format)
- font_size (int) – Size of font in pixels
- color (tuple) – Text color
- selected_color (tuple) – Text color when widget is selected
- background_color (tuple) – Font background color
- antialias (bool) – Determines if antialias is applied to font (uses more processing power)
Returns: None
Set the length of the page control area.
Parameters: value (int, float) – Length of the area Returns: None
Set Widget margin.
Parameters: Returns: None
Set widget max width (column support) if force_fit_text is enabled.
Parameters: width (int, float, None) – Width in px, None if max width is disabled Returns: None
Set menu reference.
Parameters: menu ( pygame_menu.Menu
) – Menu objectReturns: None
Set the scroll bar orientation to vertical or horizontal.
Parameters: orientation (str) – Widget orientation, could be ORIENTATION_HORIZONTAL / ORIENTATION_VERTICAL Returns: 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.
Parameters: value (int, float) – Page step Returns: None
Set the position.
Parameters: Returns: None
Mark the widget as selected.
Parameters: selected (bool) – Set item as selected Returns: None
Set the selection effect handler.
Parameters: selection ( pygame_menu.widgets.core.Selection
) – Selection effect classReturns: None
Show text shadow.
Parameters: Returns: None
Set sound engine to the widget.
Parameters: sound ( pygame_menu.sound.Sound
) – Sound objectReturns: None
Update the widget title.
Parameters: title (str) – New title Returns: None
Checks if the widget width/height has changed because events. If so, return true and set the status of the widget (menu widget position needs update) as false. This method is used by .update() from Menu class.
Returns: True if the widget position has changed by events after the rendering. Return type: bool
Update internal variable according to the given events list and fire the callbacks.
Parameters: events (list[ pygame.event.Event
]) – List of pygame eventsReturns: True if updated Return type: bool