mardi 19 mai 2020

Trying to locate and delete string in listbox in Python tktinter

Hi I am trying to see if text is in my listbox and then have it deleted but for some reason i get the error

return self.tk.call(self._w, 'cget', '-' + key)
TypeError: can only concatenate str (not "int") to str

This is my code:

from tkinter import *
import tkinter as tk
root = tk.Tk()
listboxz = Listbox(root,height=40,width=150,bg='pink')
listboxz.pack(side=tk.LEFT,fill='both',expand=True)

listboxz.insert(END, 'hi','bye','see')

if 'bye' in listboxz:
    listboxx.delete()

root.mainloop()

Thanks for your help in advance.

Aucun commentaire:

Enregistrer un commentaire