0

So lets say I have frm_one which contains the widgets lbl_one, btn_one, ent_one, etc. How could I destroy each widget in frm_one without destroying the frame itself and without explicitly naming each widget?

If I do frm_one.destroy() it destroys the whole frame. I also want to be able to destroy all widgets regardless of what is in frm_one at any given time, since it could change. This means I can't just do lbl_one.destroy() btn_one.destroy() ent_one.destroy() and so on since there might be other widgets present at any moment.

Thank you, I am willing to share more details if possible.

  • 1
    Use `for widget in frm_one.winfo_children(): widget.destroy()`. The `.winfo_children()` lists all of the frame's children and the for loop destroys each one of them – TheLizzard Jun 08 '21 at 20:38
  • This worked @TheLizzard thank you – Ignacio Cabero Jun 08 '21 at 20:41
  • 1
    A similar question: [How to delete all children elements?](https://stackoverflow.com/questions/15995783/how-to-delete-all-children-elements) – TheLizzard Jun 08 '21 at 20:42

0 Answers0