Tk_Name(3)

hey bestie! welcome to Tk_Name(3), a.k.a. the Tk Library Procedures page that’s all about converting between names and window tokens. it’s giving β€œtiny but crucial Tk lore.” πŸ’…βœ¨

✨ NAME ✨

Tk_Name, Tk_PathName, Tk_NameToWindow β€” convert between names and window tokens. periodt. πŸŽ€

✨ SYNOPSIS ✨

#include <tk.h>

Tk_Uid
Tk_Name(tkwin)

char *
Tk_PathName(tkwin)

Tk_Window
Tk_NameToWindow(interp, pathName, tkwin)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tk_Window tkwin (in) β€” token for window, bestie. 🫢
  • Tcl_Interp *interp (out) β€” interpreter to use for error reporting. it can be NULL, no cap. 😌
  • const char *pathName (in) β€” character string containing the path name of the window. πŸ¦‹

πŸ’– DESCRIPTION πŸ’–

okay so every window managed by Tk has two names, and they’re both kinda main character energy:

  • a short name that identifies a window among children of the same parent
  • a path name that identifies the window uniquely among all the windows belonging to the same main window

the path name is used more often in Tk than the short name. many commands, like bind, expect path names as arguments. iykyk. lowkey iconic.

the Tk_Name macro returns a window’s short name, which is the same as the name argument passed to Tk_CreateWindow when the window was created. the value is returned as a Tk_Uid, which may be used just like a string pointer but also has the properties of a unique identifier β€” see the manual entry for Tk_GetUid for details. slay, unique identifier behavior.

the Tk_PathName macro returns a hierarchical name for tkwin. path names have a structure similar to file names in Unix but with dots between elements instead of slashes: the main window for an application has the path name β€œ.”; its children have names like β€œ.a” and β€œ.b”; their children have names like β€œ.a.aa” and β€œ.b.bb”; and so on. a window is considered to be a child of another window for naming purposes if the second window was named as the first window’s parent when the first window was created. this is not always the same as the X window hierarchy. for example, a pop-up is created as a child of the root window, but its logical parent will usually be a window within the application. not me learning the X hierarchy isn’t always the vibe 😭

the procedure Tk_NameToWindow returns the token for a window given its path name (the pathName argument) and another window belonging to the same main window (tkwin). it normally returns a token for the named window, but if no such window exists Tk_NameToWindow leaves an error message in interpreter interp’s result and returns NULL. the tkwin argument to Tk_NameToWindow is needed because path names are only unique within a single application hierarchy. if, for example, a single process has opened two main windows, each will have a separate naming hierarchy and the same path name might appear in each of the hierarchies. normally tkwin is the main window of the desired hierarchy, but this need not be the case: any window in the desired hierarchy may be used. fr fr, any window in the desired hierarchy is valid.

πŸ”‘ KEYWORDS πŸ”‘

name, path name, token, window. that’s the whole vibe. πŸ’œ


cute sign-off: source/version is Tk, page is Tk_Name(3) β€” xoxo, the Tk library πŸ’–πŸŒΈ

πŸ“¦ where this page comes from