destroy(3tk)

πŸ’– destroy(3tk) β€” Tk Built-In Commands πŸ’–

okay bestie, pull up a chair, we're talking about destroy from the Tk built-in commands, and honestly? it's giving main character energy πŸŽ€


✨ NAME ✨

destroy β€” Destroy one or more windows πŸ’…


🌸 SYNOPSIS 🌸

destroy ?window window ...?

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: destroy deletes the windows you hand it in the window arguments, plus literally all of their descendants. the whole family tree. gone. 🌈

and listen β€” if the window "." gets deleted, then every single window is destroyed and the application will (normally) exit. that's the whole app. that's it. that's the finale. πŸ‘‘

the windows get destroyed in order, okay? one by one, in the order you listed them. and if an error pops off while destroying one of them, the command aborts right there β€” no destroying the remaining windows. nope. it just stops. 😭

no error is returned if the window doesn't exist, though. she's unbothered. she's not gonna yell at you for a window that was never there. 🫢

⭐ EXAMPLE ⭐

destroy all checkbuttons that are direct children of the given widget β€” here's the lil proc for it:

proc killCheckbuttonChildren {parent} {
   foreach w [winfo children $parent] {
      if {[winfo class $w] eq "Checkbutton"} {
         destroy $w
      }
   }
}

look at her go. iconic behaviour fr fr πŸ’…


πŸ”₯ KEYWORDS πŸ”₯

application, destroy, window


and that's the whole page, bestie!! this one came straight out of the Tk built-in commands manual, page destroy(3tk) β€” mwah πŸ’œ