Skip to content

DropDownList

Create a drop-down list the user can pick items from.

Creating a DropDownList

You can create a DropDownList using the following functions:

dropdown = DropDownList()
DropDownList(items, action, color)
Parameter Type Default Description
items list[str] [] The items to show, for example ["item1", "item2", "item3"].
action function None The function to call when an item is picked; it receives one parameter, the selected item as a string.
color Color Color.LIGHT_GRAY The dropdown's background color.
rotation int or float 0 How far to turn the dropdown, in degrees, counter-clockwise (NOTE: This can't turn the dropdown items when the list is open - only the box that holds them).
visibility int 100 How visible the dropdown is, from 0 (invisible) to 100 (fully visible).

For example,

dropdown = DropDownList(["item1", "item2", "item3"], itemSelected)

where itemSelected is a function which expects one parameter, the selected item (a string).

Once created, you can add it to a Display using the Display's add() function.

Functions

Once a DropDownList has been created, the following functions are available:

Function Description
getColor() Return the dropdown's background color.
setColor(color) Set the dropdown's background color.

Additionally, the following common functions are available: