Tcl 8.7/Tk8.7a5 Documentation > Tk Commands > systray

Tcl/Tk Applications | Tcl Commands | Tk Commands | Tcl C API | Tk C API


systray — Creates an icon display in the platform-specific system tray.


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


The tk systray create command 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>.

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

The tk systray destroy command removes the icon from display and deallocates it.

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.


Here is an example of the tk systray code:
    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:

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


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.

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.


image, callback
Copyright © 2020 Kevin Walzer/WordTech Communications LLC.