Reputation: 107
I have this tkinter GUI, where I am appending the values of entry widgets in one list and similarly entering the values of Option Menu(choices) in another list. I am facing a problem as when I delete one of my widget, its value should also be deleted in the corresponding list but it doesn't do so. Its values is still there in the list. for deleting- I am using following code
self.number_row=self.number_row-1
oneList=list(self.listFrame.grid_slaves(row=int(self.number_row)))
for l in OneList:
l.grid_remove()
and for appending-
self.entry_domain=Entry(self.listFrame)
self.entry_domain.grid(column=3,row=int(self.number_row),columnspan=2,sticky="EW")
self.entries_domain.append(self.entry_domain)
I thinking I am doing wrong in deleting the widgets
Upvotes: 0
Views: 194
Reputation: 385970
When you call grid_remove()
, you aren't deleting the widget. All you're doing is removing it from the screen. The object still exists, which is why you can still call the get
method on it.
The proper way to destroy the widget is to call the destroy()
method. However, this still won't remove it from the list. You will have to explicitly delete the object with del
(after calling destroy()
), or explicitly removing it from the list.
Upvotes: 1