Python Forum
How to delete tkinter table items? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: How to delete tkinter table items? (/thread-42378.html)



How to delete tkinter table items? - theCarl - Jun-27-2024

I have a window that is live updating with rows, but it only adds rows. I'd like to delete the old rows each refresh so that it appears as a live table. Heres what I have so far:

 filename = 'exampleFile.csv'
        
        #this keeps adding rows; need to delete rows at end of cycle
        while(1):
            with open(filename, 'r') as file:
                reader = csv.reader(file)
                for row in reader:
                    ##value = row
                    #this adds the rows, need to delete afterwards
                    self.table.addItem(f'among ', f'{row}')
                    
                time.sleep(1)
             

            self.update()
            time.sleep(1)
            file.close()
I've tried "del row" but that obviously just deletes the rows from the reader object instead of deleting the items from the table. There doesn't seem to be a clean way to remove items from the table?


RE: How to delete tkinter table items? - Gribouillis - Jun-27-2024

What is the type of self.table ? Surely that type is documented somewhere.