using map lambda to destroy widgets tkinter

  lambda, python, tkinter

I’m learning some in built functions for python, and I tried using the map and lambda function to destroy child widgets of a frame, but it didn’t work.

Here’s what I tried:

from tkinter import *

root = Tk()

C = Canvas(root, bg='red',width=400,height=400)
C.pack()

Label(C,text='Label').pack()

Button(C,text='Button').pack()

map(lambda child: child.destroy(), C.winfo_children())

root.mainloop()

Source: Python Questions

LEAVE A COMMENT