[Tutor] I get an error while search in my Entry field

Alan Gauld alan.gauld at yahoo.co.uk
Mon Jun 18 04:24:17 EDT 2018


On 17/06/18 23:59, Ali M wrote:

>     def update_list(self):
>         search_term = self.search_var.get()
>         self.listbox.delete(0, tk.END)
>         for item in self.listbox:

The above pair of lines look odd.
You delete everything on the listbox then try to iterate
over it? Is that really what you want?

Also are you sure you can iterate over a listbox widget?
I was not aware of that capability and can see nothing
about iterators in the listbox help screen...

I usually use the get() method to fetch the contents
before trying to iterate over them:

for item in myList.get(0,tk.END):
   # use item

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list