Web Analytics Made Easy - Statcounter
Skip to content

Listbox

A List Box. Provide a list of values for the user to choose one or more of. Returns a list of selected rows when a window.read() is executed.

Listbox(
    values,
    default_values = None,
    select_mode = None,
    change_submits = False,
    enable_events = False,
    bind_return_key = False,
    size = (None, None),
    disabled = False,
    auto_size_text = None,
    font = None,
    background_color = None,
    text_color = None,
    key = None,
    pad = None,
    tooltip = None,
    visible = True,
    size_px = (None, None)
)

Parameter Descriptions

Name Type Default Description
auto_size_text bool None True if element should be the same size as the contents
background_color str None color of background
bind_return_key bool False If True, then the return key will cause a the Listbox to generate an event
change_submits bool False DO NOT USE. Only listed for backwards compat - Use enable_events instead
default_values List[Any] None which values should be initially selected
disabled bool False set disable state for element
font (str or (str, int[, str]) or None) None specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
key str or int or tuple or object None Used with window.find_element and with return values to uniquely identify this element
pad (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) None Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
select_mode [enum] None Select modes are used to determine if only 1 item can be selected or multiple and how they can be selected. Valid choices begin with "LISTBOX_SELECT_MODE_" and include: LISTBOX_SELECT_MODE_SINGLE LISTBOX_SELECT_MODE_MULTIPLE LISTBOX_SELECT_MODE_BROWSE LISTBOX_SELECT_MODE_EXTENDED
size (int, int) or (int, None) or int (None, None) w=characters-wide, h=rows-high. If an int instead of a tuple is supplied, then height is auto-set to 1
size_px (int, int) or (None, None) (None, None) w=pixels-wide, h=pixels-high
text_color str None color of the text
tooltip str None text, that will appear when mouse hovers over the element
values List[Any] or Tuple[Any] list of values to display. Can be any type including mixed types as long as they have str method
visible bool True set visibility state of the element (Default = True)

Class Properties

This class has no public properties

Class Methods

 def get_list_values
 def update

get_list_values

Returns list of Values provided by the user in the user's format

get_list_values()

Parameter Descriptions

Name Type Default Description
RETURN List[Any] List of values. Can be any / mixed types -> []

update

Changes some of the settings for the Listbox Element. Must call Window.Read or Window.Finalize prior Changes will not be visible in your window until you call window.read or window.refresh.

If you change visibility, your element may MOVE.

update(
    values = None,
    disabled = None,
    set_to_index = None,
    background_color = None,
    text_color = None,
    font = None,
    visible = None
)

Parameter Descriptions

Name Type Default Description
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
disabled bool None disable or enable state of the element
font (str or (str, int[, str]) or None) None specifies the font family, size. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
set_to_index int or list or tuple None highlights the item(s) indicated. If parm is an int one entry will be set. If is a list, then each entry in list is highlighted
text_color str None element's text color. Can be in #RRGGBB format or a color name "black"
values List[Any] None new list of choices to be shown to user
visible bool None control visibility of element