Skip to content

Scrollable

ScrollableRow / ScrollableColumn

A scrollable container (a ScrollBar appears if the content doesn't fit).

Specific kwargs

Argument Type Description
content [(Align, NevuObject)] initial content.
spacing int | float distance between elements(default is 30).
arrow_scroll_power int / float scroll speed using arrow keys(default is 5).
wheel_scroll_power int / float scroll speed using the mouse wheel(default is 5).
inverted_scrolling bool invert scrolling(default is False).
scrollbar_perc NvVector2 / None custom scroll bar size in percentages(default is None).
basic_alignment Align / None default item alignment(Align.LEFT for Column, Align.TOP for Row).
append_key Keys key to scroll towards end(Keys.Up for Column, Keys.Left for Row).
descend_key Keys key to scroll towards start(Keys.Down for Column, Keys.Right for Row).

Methods

Name Kwargs Description
add_item item: NevuObject, alignment: Align | None = None adds item to the layout using specified alignment.
add_items content: list batch adds a list of (Align, NevuObject) tuples.
get_offset None returns the current offset from the scroll bar.
clear None removes all items and clears the layout.
apply_scroll_bar_style style: Style applies specific style to the scroll bar.

ScrollableRow / ScrollableColumn is a subclass of: LayoutType

Use case

from nevu_ui import *
import pygame

pygame.init()

window = Window((500, 500), title = "ScrollableRow / ScrollableColumn example")

menu = Menu(window, (100%vw, 100%vh))

lbla = Label("A", [100, 50], single_instance = False)
lblb = Label("B", [100, 50], single_instance = False)
lblc = Label("C", [100, 50], single_instance = False)

content = []
for i in range(10):
    content.append((Align.LEFT, lbla))
    content.append((Align.CENTER, lblb))
    content.append((Align.RIGHT, lblc))

layout = ScrollableColumn([100*vw, 100*vh], content = content)

menu.layout = layout
while True:
    window.begin_frame()
    window.update()
    menu.update()
    menu.draw()
    window.end_frame()
from nevu_ui import *
import pyray

window = Window((500, 500), title = "ScrollableRow / ScrollableColumn example", backend = Backend.RayLib)

menu = Menu(window, (100%vw, 100%vh))

lbla = Label("A", [100, 50], single_instance = False)
lblb = Label("B", [100, 50], single_instance = False)
lblc = Label("C", [100, 50], single_instance = False)

content = []
for i in range(10):
    content.append((Align.LEFT, lbla))
    content.append((Align.CENTER, lblb))
    content.append((Align.RIGHT, lblc))

layout = ScrollableColumn([100*vw, 100*vh], content = content)

menu.layout = layout
while True:
    window.begin_frame()
    window.update()
    menu.update()
    menu.draw()
    window.end_frame()

Created with GGen v1.3.0 for nevu_ui v0.8.2