tk_optionMenu(3tk)

✨ tk_optionMenu β€” the manual page, but make it cute ✨

okay bestie, this one is from the Tk Built-In Commands manual, and it's genuinely such a little icon, you're gonna love it πŸ’–


🌸 NAME 🌸

tk_optionMenu β€” create an option menubutton and its menu πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

tk_optionMenu pathName varName value ?value value ...?

πŸ¦‹ DESCRIPTION πŸ¦‹

so this procedure is the moment fr fr. it creates an option menubutton whose name is pathName, and it also makes an associated menu to go with it. together they're the duo, the main character energy πŸ‘‘

and what do they do?? they let the user pick one of the values that you handed over in the value arguments. that's it, that's the vibe.

the current value lives in the global variable whose name you gave as varName β€” and it's ALSO displayed as the label right there in the option menubutton, so the user always knows what's selected. slay ✨

the user can click on the menubutton to pop up a menu containing all of the values, and from there select a new one. and once a new value is selected, it gets stored in the variable and shows up in the option menubutton. obsessed.

oh and psa bestie: the current value can also be changed just by setting the variable. so like, you have options, literally 😌

the return value from tk_optionMenu is the name of the menu associated with pathName. why do you care?? because it means the caller can change its configuration options or manipulate it in other ways. you get the menu handle, you get the power πŸ’ͺ


🌈 EXAMPLE 🌈

tk_optionMenu .foo myVar Foo Bar Boo Spong Wibble
pack .foo

look at her go 🫢


⭐ KEYWORDS ⭐

option menu


πŸ’œ the cute sign-off πŸ’œ

this page is from Tk, version 4.0 β€” and the manual page is tk_optionMenu(3tk), in case you need to find her again. go build something iconic, bestie πŸ§šπŸ“