Listboix.get

This commit is contained in:
PySimpleGUI 2020-02-01 11:35:42 -05:00
parent acef3604c2
commit 0b7ca7d294
1 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/python3 #!/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' port = 'PySimpleGUIQt'
@ -713,6 +713,21 @@ class Listbox(Element):
return self.Values 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 get_list_values = GetListValues
set_value = SetValue set_value = SetValue
update = Update update = Update