Tkinter: How To Write A For Loop To Destroy A List Of Labels?
I am trying to remove these elements from the grid. I was able to delete all of them by writing out one by one. I then wrote a for loop to make it expandable, then I run into thi
Solution 1:
You have already figured out the issue in those comments !
You already know that labelemployee
is a dictionary, so iterating over it will give you, by default, the keys of the dictionary. So employee
will be strings like A, B... and so on. And destroying a string object will obviously give you an error. You need to destroy the corresponding tkinter widget. So for that, you should replace employee.destroy()
with labelemployee[employee].destroy()
in the for loop.
Post a Comment for "Tkinter: How To Write A For Loop To Destroy A List Of Labels?"