S
S
Saharman2018-05-18 00:13:04
Python
Saharman, 2018-05-18 00:13:04

How to update a given listbox in Tkinter?

I have created a listbox with certain data. Therefore, I want to delete all the old data from this listbox by pressing a key and add new ones to it. How to do it ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
qlkvg, 2018-05-18
@qlkvg

A reworked piece of an old project. How to update the data after cleaning, I hope you will reach it yourself.

...
        self.textbox = Text(self.root, height=10, width=40, wrap=WORD, state='disabled')
        self.button = Button (self.root, command=self.clear_listbox)
        self.button.pack()
        self.textbox.configure(state='disabled')
        self.textbox.pack()
        self.update("my google-fu is so bad")


    def update(self, text):
        self.textbox.configure(state='normal')
        self.textbox.insert(END, text + "\n")
        self.textbox.see(END)
        self.textbox.configure(state='disabled')

    def clear_listbox(self):
        self.textbox.configure(state='normal')
        self.textbox.delete(1.0, END)
        self.textbox.configure(state='disabled')
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question