Python Forum

Full Version: ListBox Update Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm trying to update a PySimpleGui LixtBox contents on run time. I've done done that using

window['_LISTBOX_'].update(['new','value'])
The new Listbox content appears on the screen, however on the event loop I'm not able to get the line the user clicked into it, it seems to be empty.

I think I updated the values, but not the keys.

Here's how I treat the event inside the event loop

if event == '_LISTBOX_':
    print(values) # This line is printing nothing
    if len(values['_LISTBOX_']):     # if a list item is chosen
       dosomething(values['_LISTBOX_'])
I've created the Listbox with the folowing code

g.Listbox([], enable_events=True, size=(43, 10), auto_size_text=True, key='_LISTBOX_',
                    select_mode=sg.LISTBOX_SELECT_MODE_SINGLE, bind_return_key=False, change_submits=True)
I've created the Listbox empty, then I insert some content on running time.

Thanks for any help.
Please your arrange code into a runnable snippet.
Thank you