Merge pull request #2561 from PySimpleGUI/Dev-latest

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

View File

@ -1,5 +1,5 @@
#!/usr/bin/python3
version = __version__ = "0.31.0.5 Unreleased - fix for Listbox.update, Graph.change_coordinates, Added Image.Widget, return correct value with ComboBox has manual data entry, added print_to_element, multlineline update moves cursor to end, scrollable columns"
version = __version__ = "0.31.0.6 Unreleased - fix for Listbox.update, Graph.change_coordinates, Added Image.Widget, return correct value with ComboBox has manual data entry, added print_to_element, multlineline update moves cursor to end, scrollable columns, listbox.get"
port = 'PySimpleGUIQt'
@ -713,6 +713,21 @@ class Listbox(Element):
return self.Values
def get(self):
"""
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
:return: (List[Any]) The currently selected items in the listbox
"""
value = []
selected_items = [item.text() for item in self.QT_ListWidget.selectedItems()]
for v in self.Values:
if str(v) in selected_items:
value.append(v)
return value
get_list_values = GetListValues
set_value = SetValue
update = Update