TIP 325: System Tray and System Notification Access

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Author:		David N. Welton <[email protected]>, Kevin Walzer <[email protected]>
State:		Draft
Type:		Project
Tcl-Version:	8.7
Vote:		Pending
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. The C code will implement an internal "_systray" and "_sysnotify" API owing to the significantly different designs of winico and tktray. The Mac version, while new for this TIP, will follow this general design as well.

Systray Interface

tk systray create image text callback

Creates a new icon for the system tray with a Tk image, a string for display in a tooltip, and an optional callback that fires on a event.

tk systray modify option?

Modifies either the image, string, or callback.

Sysnotify Interface

tk sysnotify title message

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

Example

systray:

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

tk systray create book "Systray sample" {puts "Here is the systray output"}

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.

Copyright

This document has been placed in the public domain.