TIP 325: System Tray and System Notification Access

Login
Author:		David N. Welton <[email protected]>, Kevin Walzer <[email protected]>
State:		Final
Type:		Project
Tcl-Version:	8.7
Vote:		Done
Vote-Summary:   Accepted 5/0/0
Votes-For:      SL, JN, MC, FV, KW
Votes-Against:  none
Votes-Present:  none
Created:	25-Aug-2008
Post-History:	
Keywords:	Tk, desktop integration

Abstract

Modern operating systems have a "system tray", where programs may place an icon to indicate program status. This TIP proposes that Tk should adopt some existing code in order to permit cross platform access to this functionality. This TIP also proposes to implement system notification windows, which have become popular across all platforms.

Design

Existing code from the winico and tktray extension packages has been refactored and ported into Tk's core; this code utilizes an acceptable license in order to repurpose it for a systray command. The sysnotify command will be a new implementation. On Windows and Mac it will make use of native system API's, and on X11 it will include a conditional dependency on libnotify, falling back to a pure-Tcl implementation (derived from the "notifywindow" tklib package) if libnotify is not present.

Both the tk systray and the tk sysnotify commands will present a script-level public API implementing the proposed interface, outlined below.

Systray Interface

tk systray create -image image ?-text text? ?-button1 callback? ?-button3 callback?

Creates a new icon for the system tray with a Tk image, a string for display in a tooltip, and callbacks that fire on a Button-1 or Button-3 event.

tk systray configure ?option? ?value option value ...?

Modifies either the image, text string, or callback (Button-1 or Button-3).

tk systray destroy

Removes the icon from the systray.

Sysnotify Interface

tk sysnotify title message

Creates and display a system notification with a title and body message.

Example

systray:

image create photo book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==

tk systray create -image book -text "Systray sample" -button1 {puts "Here is the systray output"} -button3 {puts "here is another example"}

sysnotify:

tk sysnotify "Alert" "This is just a test of the Tk System Notification Code."

Implementation

A draft implementation is currently under development in the tip_325 branch.

Post-vote note

There has been a follow-up ticket opened after this TIP was voted YES, with a patch providing the tk systray exists subcommand, see 92ab429295. This feature has been committed as well.

Copyright

This document has been placed in the public domain.