tktray(n)
πΈ tktray β the manual page, bestie edition πΈ
okay so. you want a system tray icon. in Tk. on X11. and you want it to slay. this is the page for you, and it's tktray(n) in your manual shelf. let's go π
β¨ NAME β¨
tktray β System Tray Icon Support for Tk on X11
π SYNOPSIS π
package require Tcl 8.4
package require tktray ?1.0?
tktray::icon pathName ?options?
pathName balloon message ?msec_timeout?
pathName cancel message_handle
pathName bbox
pathName cget option
pathName configure ?options?
pathName docked
pathName orientation
π¦ DESCRIPTION π¦
Tktray is an extension that is able to create system tray icons. that's the whole vibe. it follows the http://www.freedesktop.org specifications when it goes looking for the system tray manager, and this protocol is supported by modern versions of KDE and Gnome panels, plus some other panel-ish applications. so basically everyone. periodt.
π COMMANDS π
π tktray::icon pathName ?options?
Make a brand new icon for the system tray. the application managing the tray gets notified about your new icon, and normally that means the icon gets added to the tray. iconic behaviour, honestly.
if there's no system tray at the moment you create the icon, the icon will just be invisible. no drama. and when a new system tray shows up? the icon gets added to it. π«Ά
since tktray 1.3, if the tray crashes and destroys your icon, it will be recreated on a new system tray when one becomes available. not me coding resilience π
-classβ theWM_CLASSattribute for the icon window. the tray manager may use the class name to remember icon position or other attributes. this name may be used for event binding as well. okay so here's the tea: for now, the real icon window is distinct from the user-specified widget β it may be recreated and destroyed several times during the icon's lifetime, whenever a system tray crashes, terminates, disappears or appears. however, tktray tries to forward click and motion events from this inner window to the user widget, so event bindings on the widget name should work as they used to. this option applies to a real icon window, not to a user-visible widget, so don't rely on it to set widget defaults from an option database: the standard"TrayIcon"class name is used for that one.-dockedβ boolean indicating whether the real icon window should be embedded into a tray when it exists. think of it as a heavier version of the-visibleoption: there's a guarantee that no place for the icon will be reserved on any tray.-imageβ image to show in the system tray. since tktray 1.3, image type"photo"is not mandatory anymore. the icon will be automatically redrawn on any image modifications. for Tk, deleting an image and creating an image with the same name later counts as a kind of image modification, and tktray follows this convention. photo image operations that modify existing image content are another example of events triggering redisplay. the requested size for the icon is set according to the image's width and height, but obeying (or disobeying) this request is left for the tray. respectfully, it's their call π-shapeβ used to put a nonrectangular shape on an icon window. ignored for compatibility. it's giving legacy, bestie.-visibleβ boolean value indicating whether the icon must be visible. the system tray manager continues to manage the icon whether it's visible or not, so when an invisible icon becomes visible, its position on the system tray is likely to remain the same. tktray currently tries to find a tray and embed into it as soon as possible, whether-visibleis true or not._XEMBED_INFOproperty is set for the embedded window: a tray should show or hide an icon depending on this property. there may be β and indeed there are β incomplete tray implementations ignoring_XEMBED_INFO(ex.docker). Gnome-panel "unmaps" an icon by making it one pixel wide, and that might be what you expect. for those implementations, the place for an icon will be reserved but no image will be displayed: tktray takes care of it. tktray also blocks mouse event forwarding for invisible icons, so you may be confident that no<Button>bindings will be invoked at this time. no surprise clicks. we love that for us.
π pathName balloon message ?msec_timeout?
Post a message that any decent tray implementation would show alongside the icon (or a place allocated for it). the message disappears automatically after $msec_timeout milliseconds.
unfortunately, there is absolutely no way to know if the tray supports this feature, so don't rely on it for any critical information to be delivered. fr fr.
when no timeout or a zero timeout is given, the message should not be hidden without user action (usually a mouse click).
the return value is an integer: a message handle that may be used for cancelling the message before the timeout expires, or zero if there is currently no system tray to handle the request. π
π pathName cancel message_handle
Cancel an earlier-posted balloon message. a zero message_handle is silently ignored. if there's no message with this handle, or its timeout has expired, or it was posted to another system tray and is unknown to the current one, nothing bad should happen β (but it depends on the tray implementation, so, yk, fingers crossed). π
β pathName bbox
Get the list of left, top, right and bottom coordinates of the icon relative to the root window of the icon's screen.
use this command in preference to winfo rootx and winfo rooty to get the icon location, though the latter may seem to work on your system. π
bounding box information is updated asynchronously. don't rely on its correctness on script startup, just after icon creation. this command is for event handlers: on <ButtonPress-3> you'd like to have a popup menu, but where should it be posted? use %W bbox to determine it right at the moment when a click happened. chef's kiss timing π
πΈ pathName cget option
Retrieve the current option value as set by the caller. that's it. that's the command.
π§ pathName configure ?options?
Modify the icon's options after it was created. glow-up support included.
π pathName docked
Query the icon whether it's currently embedded into some system tray. invisible icons may be docked too (and tktray strives for it, main character energy). if this method returns false, the icon is not visible to anyone, and there's no chance to get balloon messages displayed. π
π pathName orientation
Query the orientation of a system tray that is currently embedding the icon.
π¦ WINDOW MANAGEMENT π¦
okay so the current implementation of tktray is designed to present an interface of a usual toplevel window, but there are some important differences (and some of them may come up later, iykyk).
the System Tray specification is based on the XEMBED protocol, and that one has a problem: when the embedder crashes, nothing can prevent embedded windows from destruction. nothing. absolutely nothing. π
since tktray 1.3, no explicit icon recreation code is required on the Tcl level. the widget was split in two:
- one represented by a caller-specified name
- another (currently
$path.inner) that exists only when a tray is available (and dies and comes back and so on)
this solution has some disadvantages as well. the user-created widget is not mapped at all, so it can't be used any more as a parent for other widgets, showing them instead of an image. a temporal inner window, however, may contain widgets. so, trade-offs, bestie π«Ά
this version introduces three virtual events: <<IconCreate>>, <<IconConfigure>> and <<IconDestroy>>.
<<IconCreate>>is generated when docking is requesting for an icon.<<IconConfigure>>is generated when an icon window is resized or changed in some other way.<<IconDestroy>>is generated when an icon is destroyed due to a panel crash, or undocked with unsetting the-dockedoption.
π AUTHORS π
Anton Kovalenko β see http://www.sw4me.com/wiki/Tktray.
β KEYWORDS β
icons, system tray, taskbar
π COPYRIGHT π
Copyright (c) 2005, Anton Kovalenko
and that's the whole page, bestie π
it's from the tktray manual, version 1.0 (and it also answers to the name tktray(n)), with the copyright sitting at 2005 β go forth and put an icon in somebody's tray, you've got this πβ¨π¦
π¦ where this page comes from
- fedora 43: tktray 1.3.9-29.fc41 Β· BSD
- fedora 44: tktray 1.3.9-29.fc41 Β· BSD
- Copyright (c) 2005, Anton Kovalenko
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms