Tk_SetClass(3tk)
π Tk_SetClass, Tk_Class β setting or grabbing a window's class π
okay bestie, this is from the Tk Library Procedures girlies, and it's literally about giving your window a class (yes, like a vibe, but for window managers) π
β¨ SYNOPSIS β¨
#include <tk.h>
Tk_SetClass(tkwin, class)
Tk_Uid
Tk_Class(tkwin)
π ARGUMENTS π
Tk_Window tkwin(in) β the token for the window, aka its lil ID badge πͺͺchar *class(in) β the new class name you're assigning to the window, slay β¨
π¦ DESCRIPTION π¦
So <pink>Tk_SetClass</pink> is what you call to associate a class with one specific window. The class string is basically telling everyone what kind of window this is β the type of the window, fr fr. Every window that shares the same general class of behavior (button, menu, etc.) should have the same class, no cap. π
By convention, all class names start with a capital letter β and there's a Tcl command with the exact same name as each class (except all in lower-case) that you can use to create and manipulate windows of that class. iykyk. π
Not me forgetting this: a window's class string is initialized to NULL when the window is created. So if you want a class, you gotta set it yourself, bestie. π
For main windows, Tk automatically propagates the name and class over to the WM_CLASS property that window managers use. The way that works: this happens either when a main window is actually created (e.g. in Tk_MakeWindowExist), or when Tk_SetClass is called β whichever occurs later. β°
And if a main window has not been assigned a class? Then Tk will not set the WM_CLASS property for that window. Periodt. π
Now, <purple>Tk_Class</purple> is a macro that returns the current value of tkwin's class. It comes back as a Tk_Uid, which you can use just like a string pointer, but it also has the properties of a unique identifier (peep the manual entry for Tk_GetUid for the details, bestie π«Ά).
If tkwin has not yet been given a class, then Tk_Class will return NULL. iconic behavior honestly π
β KEYWORDS β
class, unique identifier, window, window manager
and that's the whole page, babe π§π this gem comes to you from Tk, dated with the Tk_SetClass(3tk) footer energy β go forth and class-ify ur windows, you main character πΈπ
π¦ 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) 1990 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