Title: Python Tkinter Listbox.delete(0, END) does not seem to work inside a class
Tags: python,python-3.x,tkinter,listbox

Question: I was creating a GUI class which inherited tk.TK to make a tk app and while using Listbox inside a seperate Frame, I ran into this problem where Listbox.delete(0, END) does not work inside the class. I added a command to a button that is supposed to do stuff alongside clearing the listbox of all its entries to refresh it for new ones. It works in other programs where its outside of a class. It shows no error or anything it just straight up doesn't work. is `Tkinter` supposed to work differently in classes?
Here's the code
from tkinter import *
from tkinter import font

class GUI(Tk):
    def __init__(self, title, geometry) -> None:
        super().__init__()
        self.title(title)
        self.geometry(geometry)
        self.configure(background="grey")

        self._listFont = font.Font(family='Calibri', size=10, weight='bold')    

        self._searchFrame = self._createFrame(self, "grey")
    
        self._searchBox =  self._createEntryBox(self._searchFrame, Side=LEFT)
        self._searchButton = self._createButton(self._searchFrame, "Search", self._onSearchButtonClick, RIGHT)

        self._resultsFrame = self._createFrame(self, "grey")

        self._resultsScrollbar = Scrollbar(self._resultsFrame)
        self._resultsScrollbar.pack(side=RIGHT, fill=BOTH, pady=10)

        self._resultsList = Listbox(self._resultsFrame)
        self._resultsList.pack(side=LEFT, fill=X, pady=10)
        self._resultsList.configure(background='grey', font=self._listFont, width=370)

        self._resultsList.config(yscrollcommand = self._resultsScrollbar.set)
        self._resultsScrollbar.config(command = self._resultsList.yview)
    

    def _createFrame(self, context, bgColor):
        f = Frame(context, bg=bgColor)
        f.pack()
        return f
    
    def _onSearchButtonClick(self):
        self._resultsList.delete(0, END)
        query = self._searchBox.get()
        self._searchBox.delete(0, END)
       
        titles = ['Title 1', 'Title 2', 'Title 3']

        for i, title in enumerate(titles, start=1):
            titleName = title
            itemString = f'{i}. {titleName}'
            self._resultsList.insert(END, itemString)

        self._resultsList.see(END)


    def _createEntryBox(self, context, entryval='', font='Calibri 12', fill=X, Side=LEFT):
        entryValue = StringVar().set(entryval)
        entryBox = Entry(context, textvariable=entryValue, font=font)
        entryBox.pack(fill=X, ipadx=20, padx=3, pady=10, side=Side)
        return entryBox

    def _createButton(self, context, text, callback, Side):
        button = Button(context, text=text, command=callback)
        button.pack(side=Side, padx=1, pady=10)
        return button

if __name__ == "__main__":
    appTitle = "My GUI App"
    appGeometry = "744x377"

    app = GUI(appTitle, appGeometry)
    app.mainloop()


I tried to be as clear and descriptive as possible

Answer: It seems that the API I used to get the data returned a List that kept on appending new values without clearing out the previous ones first. I changed the program to clear that list first and now it works perfectly so I'm closing the question