Python Forum
[PySimpleGUI] update listbox not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PySimpleGUI] update listbox not working
#1
I am trying to update a listbox in PySimpleGUI.I have a listbox with a key, so I use this code:
test=['aaaa','bbbb','cccc']
window.FindElement('_OUTPUT_').Update(values=test)
I get this error:
window.FindElement('_OUTPUT_').Update(values=test)
File "/Users/richard/anaconda/lib/python3.5/site-packages/PySimpleGUI/PySimpleGUI.py", line 719, in Update
self.TKListbox.delete(0, 'end')
AttributeError: 'NoneType' object has no attribute 'delete'

It is as if the listbox with '_OUTPUT_' key is not found...
Reply
#2
Here is the full code:
import PySimpleGUI as sg
from SQLiteClient import *

##########################
name = 'Pi3B+'
##########################
conf = db()
otherIP = conf.select('select IP from nodes where name="%s" ' % name)[0][0]
layout = [
	[sg.Listbox(values=[], key='_OUTPUT_', size=(30, 6))],
    [sg.Submit(), sg.Cancel()]
     ]
window = sg.Window('ToDo').Layout(layout)
clint = client(otherIP, 8889)
clint.sendSQL('select first_name from employees')
ret = clint.checkQ()
print(ret)

test=['aaaa','bbbb','cccc']
window.FindElement('_OUTPUT_').Update(values=test)
button, values = window.Read()
And here is the output:
/Users/richard/anaconda/bin/python3.5 /Users/richard/PycharmProjects/ToDo/todos.py
config.sqlite
config.sqlite
SQLiteClient clienting on ('0.0.0.0', 8889)
[['Jim'], ['Jim'], ['Jim'], ['John'], ['Susan']]
Traceback (most recent call last):
File "/Users/richard/PycharmProjects/ToDo/todos.py", line 24, in <module>
window.FindElement('_OUTPUT_').Update(values=test)
File "/Users/richard/anaconda/lib/python3.5/site-packages/PySimpleGUI/PySimpleGUI.py", line 719, in Update
self.TKListbox.delete(0, 'end')
AttributeError: 'NoneType' object has no attribute 'delete'
Reply
#3
Apparently I had to use Finalize() on the layout line, like this:
window = sg.Window('ToDo').Layout(layout).Finalize()

Since the window is not fully formed until then...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PysimpleGUI window update dynamically SamLiu 6 3,888 Apr-05-2023, 02:32 PM
Last Post: SamLiu
Photo PySimpleGUI FilesBrowse enable event to update value in combo SamLiu 2 4,467 Mar-15-2023, 12:49 PM
Last Post: SamLiu
  PysimpleGUI - listbox with list jamesaarr 2 4,231 Sep-06-2021, 09:52 AM
Last Post: jamesaarr
  [PyGUI] ListBox Update Issue antonello 1 3,128 Feb-28-2021, 06:23 PM
Last Post: Larz60+
  [PySimpleGUI]How to insert values that were gotten from FilesBrowse into ListBox? trigchen 0 2,857 Dec-30-2019, 06:58 AM
Last Post: trigchen
  Need help setting up a PySimpleGUI progress bar that I can maually update in script Soundtechscott 1 10,044 Jun-10-2019, 06:14 AM
Last Post: Soundtechscott
  listbox ipadx, ipady not working maxtimbo 4 4,818 Feb-22-2019, 07:46 PM
Last Post: wuf

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020