tk(systray)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05

πŸ’– tk(systray) β€” Tk's system tray page πŸ’–

okay bestie, welcome to the tk(systray) manual from Tk. This whole page is about creating an icon display in the platform-specific system tray, and it is lowkey iconic. πŸ’…βœ¨


✨ NAME ✨

systray β€” creates an icon display in the platform-specific system tray. πŸŽ€

🌸 SYNOPSIS 🌸

tk systray create -image image ?-text text? ?-button1 callback? ?-button3 callback?
tk systray configure ?option? ?value option value ...?
tk systray exists
tk systray destroy

πŸŽ€ DESCRIPTION πŸŽ€

tk systray create creates an icon in the platform-specific tray. The widget is configured with a Tk image for the icon display, an optional string for display in a tooltip, and optional callbacks that are bound to <Button-1> and <Button-3>. Main character behavior, honestly. πŸ’–

tk systray configure sets one or more options of the systray icon. The configurable options are the same as for the create subcommand. When a single option name is given, the command returns the current value of this option. When no option is given, this command returns the list of all options and their current value. Very demure, very mindful. ✨

tk systray exists checks whether a systray icon was created. It returns a boolean. 🫢

tk systray destroy removes the icon from display and deallocates it. Gone, gone, gone. πŸ’€

From a user-interface standpoint, only one icon per interpreter is supported; attempts to create additional icons will return an error. The existing tray icon can be modified with different images and strings to indicate app state. Loading additional interpreters into a running instance of Wish will allow additional icons to be displayed. Important lore, bestie. πŸ‘‘

πŸ’… EXAMPLE πŸ’…

Here is an example of the tk systray code. Copy it exactly, no cap:

image create photo book -data \
        R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
tk systray create -image book -text "tk systray sample" \
        -button1 {puts "Here is the tk systray output"} \
        -button3 {puts "here is alternate output"}

Here is an example of modifying the tk systray icon β€” glow-up edition:

image create photo book_page -data \
        R0lGODlhCwAPAKIAAP//////AMDAwICAgAAA/wAAAAAAAAAAACwAAAAACwAPAAADMzi6CzAugiAgDGE68aB0RXgRJBFVX0SNpQlUWfahQOvSsgrX7eZJMlQMWBEYj8iQchlKAAA7
tk systray configure -image book_page -text "Updated sample" \
        -button1 {puts "Different output from the tk systray"} \
        -button3 {puts "and more different output from the tk systray"}

πŸ”₯ PLATFORM NOTES πŸ”₯

The X11 implementation is supported on a "best efforts" basis because it is dependent on the window manager. The "text" flag, which is implemented as a tooltip, does not always display if the WM does not support such features; the systray icon itself may not even display with some window managers. So X11 is giving "we'll try our best" energy. 😭

On Windows, the Tk image provided in the -image option must be a photo image. On other platforms either a bitmap image or a photo image may be provided. Windows girlies, photo image only. πŸͺŸβœ¨

πŸ‘‘ KEYWORDS πŸ‘‘

image, callback


That's the tea from the systray page πŸ’–πŸ«Ά β€” footer sign-off: this copy shows source/version marker n and manual name tk(systray), and there's no date printed in the final line, so we're not inventing one. No cap, just vibes. πŸŽ€

πŸ“¦ where this page comes from