title: tkinter: cleanly destroy auto-wrapping widgets created in tk.Text with window_create
body: <p>Based on <a href="https://stackoverflow.com/a/69846761/13525512">this</a> answer, I successfully created my own widget where labels are wrapped automatically in a <code>Text</code> element using <code>window_create</code>.</p>
  <p>I'm also able to destroy these labels using <code>nametowidget</code>. However, the <code>window</code> element of the deleted widgets remains and is returned by <code>dump</code>.</p>
  <p>Here is my minimal reproducible example:</p>
  <pre><code>import tkinter as tk
  
  root = tk.Tk()
  
  btn_frame1 = tk.Frame(root)
  btn_frame1.pack(side='top', fill='x')
  create_labels_btn = tk.Button(btn_frame1, text='Create Labels')
  create_labels_btn.pack(side='left')
  delete_labels_btn = tk.Button(btn_frame1, text='Delete Labels')
  delete_labels_btn.pack(side='right')
  
  label_text_field = tk.Text(root, height=7, width=40)
  label_text_field.pack(side='top')
  
  dump_text_field_btn = tk.Button(root, text='Dump text field')
  dump_text_field_btn.pack(side='top')
  
  dumping_text = tk.Text(root, height=7, width=40)
  dumping_text.pack(side='top')
  
  def create_labels():
      for i in range(1, 7):
          lbl = tk.Label(label_text_field, width=12, text=f'label {i}')
          label_text_field.window_create(&quot;insert&quot;, window=lbl, padx=8, pady=8)
  
  create_labels_btn['command'] = create_labels
  
  def delete_labels():
      for lbl in label_text_field.dump(&quot;1.0&quot;, &quot;end&quot;):
          if lbl[0] =='window' and lbl[1]:
              label_text_field.nametowidget(lbl[1]).destroy()
  
  delete_labels_btn['command'] = delete_labels
  
  def dump_text_field():
      dumping_text.delete(&quot;1.0&quot;, &quot;end&quot;)
      for obj in label_text_field.dump(&quot;1.0&quot;, &quot;end&quot;):
          dumping_text.insert('end', str(obj) + '\n')
  
  dump_text_field_btn['command'] = dump_text_field
  
  root.mainloop()
  </code></pre>
  <p>After creating and deleting my labels. The deleted elements are still visible in the <code>dump</code> output (the widget was succesfully deleted though and the remaining name is only an empty string):</p>
  <p><a href="https://i.stack.imgur.com/OvAfe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OvAfe.png" alt="enter image description here" /></a></p>
  <p>How can I cleanly remove the associated <code>window</code> so that they don't add up over time?</p>