tkwait(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– tkwait β€” the Tk built-in that just… waits πŸ’–

okay bestie, pull up a chair (or a beanbag, no judgement) because we're talking about tkwait, a Tk built-in command, and honestly? it's giving patient queen energy. ✨


✨ NAME ✨

tkwait β€” wait for a variable to change, or for a window to be destroyed πŸ¦‹


🌸 SYNOPSIS 🌸

tkwait variable name
tkwait visibility name
tkwait window name

πŸ’… DESCRIPTION πŸ’…

okay so. the tkwait command waits for one of several things to happen, and then it returns without taking any other actions. that's it. that's the whole job. it waits, and then it's done. main character who minds her own business. πŸ’–

the return value is always an empty string. literally always. don't go looking for a payload, there isn't one, it's just vibes and an empty string. 😭

now let's break down the three forms, because the first argument is the whole personality here:

  • if the first argument is variable (or any abbreviation of it) β€” then the second argument is the name of a global variable, and the command waits for that variable to be modified. like, it's stalking the variable (affectionately). πŸ‘€
  • if the first argument is visibility (or any abbreviation of it) β€” then the second argument is the name of a window, and tkwait waits for a change in its visibility state, as indicated by the arrival of a VisibilityNotify event. this form is typically used to wait for a newly-created window to appear on the screen before taking some action. so like, waiting for your friend to actually show up to the party before you start the group photo. πŸŽ€
  • if the first argument is window (or any abbreviation of it) β€” then the second argument is the name of a window, and tkwait waits for that window to be destroyed. this form is typically used to wait for a user to finish interacting with a dialog box before using the result of that interaction. it's the "i'll wait until you're done clicking, bestie" form and honestly? respectful. 🫢

πŸ¦‹ while it's waiting πŸ¦‹

while the tkwait command is waiting, it processes events in the normal fashion, so the application will continue to respond to user interactions. yes, the app is still alive, it's not frozen, breathe. πŸ’œ

and here's the lil twist: if an event handler invokes tkwait again, the nested call to tkwait must complete before the outer call can complete. nesting dolls. no skipping ahead. the inner one has to finish its sentence first. periodt. πŸ‘‘


🌈 SEE ALSO 🌈


⭐ KEYWORDS ⭐

variable, visibility, wait, window


that's the whole page, bestie!! this one comes to you from Tk, filed under the page name tkwait(3tk), and ngl it was a delight. go wait on something. slay. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from