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,
    k = None,
    pad = None,
    tooltip = None,
    visible = True,
    size_px = (None, None),
    metadata = 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
enable_events bool False Turns on the element specific events. Listbox generates events when an item is clicked
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
k str or int or tuple or object None Same as the Key. You can use either k or key. Which ever is set will be used.
key str or int or tuple or object None Used with window.find_element and with return values to uniquely identify this element
metadata Any None User metadata that can be set to ANYTHING
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

Class Properties

This class has no public properties

Class Methods

 def expand
 def get
 def get_list_values
 def get_stylesheet
 def set_stylesheet
 def set_value
 def update

expand

WARNING - NOT USED IN PySimpleGUIQt port. Provided as dummy method

expand(
    expand_x = False,
    expand_y = False,
    expand_row = True
)

Parameter Descriptions

Name Type Default Description
expand_row bool True If True the row containing the element will also expand. Without this your element is "trapped" within the row
expand_x bool False If True Element will expand in the Horizontal directions
expand_y bool False If True Element will expand in the Vertical directions
RETURN None None

get

Gets the current value of the Element as it would be represented in the results dictionary. Normally you would NOT be using this method, but instead using the return values dictionary that is returned from reading your window

get()

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 -> []

get_stylesheet

Returns the stylesheet for element's associated Qt Widget

get_stylesheet()

Parameter Descriptions

Name Type Default Description
RETURN str stylesheet

set_stylesheet

Sets the stylesheet for a Qt Widget

set_stylesheet(
    stylesheet
)

Parameter Descriptions

Name Type Default Description
stylesheet str Stylesheet (string) to set stylesheet to

set_value

Set listbox highlighted choices

set_value(
    values
)

Parameter Descriptions

Name Type Default Description
values List[Any] or Tuple[Any] new values to choose based on previously set values

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