tk(3tk)
β¨ 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 anewName, it returns the name of the application (that's the name you'd use insendcommands to talk to the app). if you do give it anewName, then boom, the app's name gets changed tonewName. 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,newNameshould 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 thesendcommand? this command will reenable them and recreate thesendcommand. 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 thebusymanual 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.-xand-yare window-relative coordinates, and-heightis 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-displayofoption is given, then the return value refers to the display ofwindow; 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 thefontchoosermanual page β¨.tk print windowβ thetk printcommand posts a dialog that lets users print output from thecanvasandtextwidgets. the printing gets done using platform-native APIs and dialogs where available π¨οΈ. more details in theprintmanual 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 π. thenumberargument is a floating point number specifying the number of pixels per point onwindow's display. if you omit thewindowargument, it defaults to the main window. if you omit thenumberargument, 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?β thetk sysnotifycommand 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 thesysnotifymanual page.tk systray create subcommand...β thetk systraycommand creates an icon in the platform-specific tray π§. more details in thesystraymanual 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 return0. if thewindowargument is omitted, it defaults to the main window. if thebooleanargument 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 ofx11(X11-based),win32(MS Windows), oraqua(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
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1992 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms