tk(3tk)

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

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

okay bestie, welcome to tk(3tk), a page from the Tk Built-In Commands collection πŸ’…


🌸 NAME 🌸

tk β€” manipulate Tk internal state


πŸŽ€ SYNOPSIS πŸŽ€

tk option ?arg ...?

πŸ’– DESCRIPTION πŸ’–

so the tk command is your all-access pass to the lil behind-the-scenes bits of Tk's internal state 🫢. ngl, most of the stuff this command pokes at is about the application as a whole, or about a screen or display β€” not about one specific window. it's giving main-character-of-the-whole-app energy, not "this one little window" energy.

the command can shapeshift into a bunch of different forms depending on the option argument, and the legal ones are literally these:

  • tk appname ?newName? β€” if you don't hand it a newName, it returns the name of the application (that's the name you'd use in send commands to talk to the app). if you do give it a newName, then boom, the app's name gets changed to newName. heads up though: if that name is already taken, a suffix like " #2" or " #3" gets appended so the name stays unique, and the command's result is the name it actually picked. also, newName should not start with a capital letter β€” that would mess with option processing, because names starting with capitals are assumed to be classes, and as a result Tk might not be able to find some options for the application 😭. oh and if sends got disabled by deleting the send command? this command will reenable them and recreate the send command. iconic.
  • tk busy subcommand ... β€” this one controls the marking of window hierarchies as "busy", which renders them non-interactive while some other operation is doing its thing. for more deets, go read the busy manual page πŸ“–.
  • tk caret window ?-x x? ?-y y? ?-height height? β€” sets and queries the caret location for the display of the specified Tk window, window. the caret is the per-display cursor location used for indicating global focus (like, to comply with Microsoft Accessibility guidelines πŸͺŸ), and also for locating the over-the-spot XIM (X Input Methods) or Windows IME windows. if you pass no options at all, the last values used for setting the caret get returned in option-value pair format. -x and -y are window-relative coordinates, and -height is the height of the current cursor location β€” or the height of the specified window if none is given.
  • tk inactive ?-displayof window? ?reset? β€” returns a positive integer: the number of milliseconds since the last time the user interacted with the system ⏱️. if the -displayof option is given, then the return value refers to the display of window; otherwise it refers to the display of the application's main window.

tk inactive will return -1 if querying the user inactive time isn't supported by the system, and also in safe interpreters. noted, bestie.

if the literal string reset is given as an additional argument, the timer is reset and an empty string is returned. > ⚠️ resetting the inactivity time is forbidden in safe interpreters and will throw an error if you try it. don't try it. seriously.

  • tk fontchooser subcommand ... β€” controls the Tk font selection dialog. more details live in the fontchooser manual page ✨.
  • tk print window β€” the tk print command posts a dialog that lets users print output from the canvas and text widgets. the printing gets done using platform-native APIs and dialogs where available πŸ–¨οΈ. more details in the print manual page.
  • tk scaling ?-displayof window? ?number? β€” sets and queries the current scaling factor Tk uses to convert between physical units (think points, inches, or millimeters) and pixels πŸ“. the number argument is a floating point number specifying the number of pixels per point on window's display. if you omit the window argument, it defaults to the main window. if you omit the number argument, the current value of the scaling factor is returned.

a "point" is a unit of measurement equal to 1/72 inch. a scaling factor of 1.0 corresponds to 1 pixel per point, which is equivalent to a standard 72 dpi monitor. a scaling factor of 1.25 would mean 1.25 pixels per point, which is the setting for a 90 dpi monitor; setting the scaling factor to 1.25 on a 72 dpi monitor would cause everything in the application to be displayed 1.25 times as large as normal 😳. the initial value for the scaling factor is set when the application starts, based on properties of the installed monitor, but it can be changed at any time. measurements made after the scaling factor is changed will use the new scaling factor, but it is undefined whether existing widgets will resize themselves dynamically to accommodate the new scaling factor. so like, be aware bestie.

  • tk sysnotify title? message? β€” the tk sysnotify command creates a platform-specific system notification alert πŸ””. its intent is to provide a brief, unobtrusive notification to the user by popping up a window that briefly appears in a corner of the screen. more details in the sysnotify manual page.
  • tk systray create subcommand... β€” the tk systray command creates an icon in the platform-specific tray 🧚. more details in the systray manual page.
  • tk useinputmethods ?-displayof window? ?boolean? β€” sets and queries the state of whether Tk should use XIM (X Input Methods) for filtering events. the resulting state is returned. XIM is used in some locales (i.e., Japanese, Korean) to handle special input devices. this feature is only significant on X 🐧. if XIM support isn't available, this will always return 0. if the window argument is omitted, it defaults to the main window. if the boolean argument is omitted, the current state is returned. this is turned on by default for the main display πŸ‘‘.
  • tk windowingsystem β€” returns the current Tk windowing system, one of x11 (X11-based), win32 (MS Windows), or aqua (macOS Aqua) 🌈.

πŸ¦‹ SEE ALSO πŸ¦‹

busy(3tk), fontchooser(3tk), print(3tk), send(3tk), sysnotify(3tk), systray(3tk), winfo(3tk)


πŸ’œ KEYWORDS πŸ’œ

application name, print, send, sysnotify, systray


and that's the whole page, bestie, you ate it πŸ“ this was tk(3tk) from Tk 8.4 β€” mwah, go forth and manipulate that internal state βœ¨πŸ’…


πŸ“¦ where this page comes from