Merge pull request #2562 from PySimpleGUI/Dev-latest

Listbox.get
This commit is contained in:
PySimpleGUI 2020-02-01 11:46:10 -05:00 committed by GitHub
commit d8919b44cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3
version = __version__ = "4.15.1.6 Unreleased - Fix for draw_pixel, fix Multline.update with no value specified, listbox update no longer selects a default, all justifications can be shortened to single letter, fix for debug window closed with Quit button, removed f-string, draw_polygon added, print_to_element added"
version = __version__ = "4.15.1.7 Unreleased - Fix for draw_pixel, fix Multline.update with no value specified, listbox update no longer selects a default, all justifications can be shortened to single letter, fix for debug window closed with Quit button, removed f-string, draw_polygon added, print_to_element added, Listbox.get"
port = 'PySimpleGUI'
@ -1412,6 +1412,23 @@ class Listbox(Element):
"""
return self.TKListbox.curselection()
def get(self):
"""
Returns the list of items currently selected in this listbox. It should be identical
to the value you would receive when performing a window.read() call.
:return: (List[Any]) The list of currently selected items. The actual items are returned, not the indexes
"""
try:
items = self.TKListbox.curselection()
value = [self.Values[int(item)] for item in items]
except:
value = []
return value
get_indexes = GetIndexes
get_list_values = GetListValues
set_focus = Element.SetFocus