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, textColor, font, rotation, visibility)
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.WHITE The dropdown's background color.
textColor Color Color.BLACK The text color.
font Font None The font, for example Font("Serif", Font.ITALIC, 16). If omitted, the default font (Arial, size 13) is used.
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
getText() Return the selected item.
setText(text) Select the item with the given text.
getColor() Return the dropdown's background color.
setColor(color) Set the dropdown's background color.
getTextColor() Return the dropdown's text color.
setTextColor(color) Set the dropdown's text color.
getFont() Return the dropdown's font.
setFont(font) Set the dropdown's font.

Additionally, the following common functions are available: