tk(systray)

πŸ“¦
version 9.0.4 Β· 2 versions
, in ubuntu stonking

✨ tk(systray) ✨

okay bestie, this is the tk(systray) page from the Tk manual, and it's literally all about putting a cute little icon in your system tray. let's get into it πŸ’…


🌸 NAME 🌸

systray β€” creates an icon display in the platform-specific system tray. no cap, that's the whole vibe: one tiny icon, living its best life in your 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 πŸ’–

so the tk systray create command makes an icon in the platform-specific tray. that's it, that's the main character moment. ✨ the widget gets configured with a Tk image for the icon display, an optional string that shows up in a tooltip, and optional callbacks that get bound to <Button-1> and <Button-3>. clicky clicky, bestie πŸ–±οΈ

the tk systray configure command sets one or more options of the systray icon. and the configurable options? the same as for the create subcommand, so no surprises there πŸ’€

a few lil' details on configure specifically:

  • when you give it a single option name, it returns the current value of that option. like, "hey what's your deal right now?"
  • when you give it no option at all, it returns the list of all options and their current value. a full lil' report card πŸ’…

the tk systray exists command checks whether a systray icon was created β€” and it returns a boolean, because of course it does. true/false, yes/no, slay/not slay 🌈

the tk systray destroy command removes the icon from display and deallocates it. rip little icon, you served 🌸

🫢 important UI tea: from a user-interface standpoint, only one icon per interpreter is supported. attempts to create additional icons will return an error. no cap. the existing tray icon can be modified with different images and strings to indicate app state β€” and if you want more icons, loading additional interpreters into a running instance of Wish will allow additional icons to be displayed. periodt.

🌈 EXAMPLE 🌈

here's an example of the tk systray code, bestie:

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"}

and here's 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 πŸ¦‹

okay this part is important so pay attention πŸ”₯

  • X11: 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 β€” and honestly? the systray icon itself may not even display with some window managers. it's giving chaos 😭
  • Windows: on Windows, the Tk image provided in the -image option must be a photo image. non-negotiable.
  • Other platforms: on other platforms, either a bitmap image or a photo image may be provided. flexible icon energy ✨

πŸ‘‘ KEYWORDS πŸ‘‘

image, callback


and that's the whole page, bestie!! πŸŽ€ this came from the n source and it's the tk(systray) page β€” go forth and put an icon in your tray, you've got this πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from