Skip to content

list_view

pdwidgets.widgets.list_view

Scrollable list container.

ListView(parent, x=0, y=0, w=None, h=None, align=None, align_to=None, fg=None, bg=None, visible=True, padding=None)

Bases: Widget

Vertically scrollable list container.

Initialize a ListView widget to display a list of items.

Parameters:

Name Type Description Default
parent Widget

The parent widget or screen that contains this list view.

required
x int

The x-coordinate of the list view.

0
y int

The y-coordinate of the list view.

0
w int

The width of the list view.

None
h int

The height of the list view.

None
align int

The alignment of the list view.

None
align_to Widget

The widget to align to.

None
fg int

The color of the list view.

None
bg int

The background color of the list view.

None
visible bool

The visibility of the list view.

True
padding tuple

The padding on each side of the list view.

None
Usage

list_view = ListView(screen) button1 = Button(list_view, label="Button 1", value=1) button2 = Button(list_view, label="Button 2", value=2)

add_child(child)

Adds a child widget to the current widget.

changed()

Update the list view when the value changes.

config_scrollbar()

Configure the scrollbar based on the number of children.

reassign_positions()

Reassign the positions of all children after one is removed.

remove_child(child)

Removes a child widget from the current widget.

scroll(sender)

Read the value of the scrollbar and scroll the list view accordingly.

scroll_down()

Scroll the list view down by one item.

scroll_up()

Scroll the list view up by one item.