From d6c1639412fcfd0e262af10918fe88da2b8029eb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 16 Jan 2012 01:49:17 +0000 Subject: [PATCH 1/1] an applet --- .gitignore | 1 + example | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .gitignore create mode 100755 example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/example b/example new file mode 100755 index 0000000..fe97943 --- /dev/null +++ b/example @@ -0,0 +1,49 @@ +#!/usr/bin/wish8.4 + +#----- general machinery ----- + +package require tktray + +wm withdraw . + +image create bitmap ims -file /usr/share/ghostscript/8.71/lib/gs_s.xbm + +tktray::icon .i -class example +.i configure -docked 1 + +set posted 0 + +foreach b {1 3} { + menu .m$b -tearoff 0 +} + +proc pressed {b x y} { + global posted + if {$posted == $b} { + puts "unpost $posted toggle" + .m$posted unpost + set posted 0 + } elseif {[winfo exists .m$b]} { + if {$posted} { + .m$posted unpost + puts "unpost $posted other" + } + puts "post $b" + set posted $b + .m$b post $x $y + } +} + +proc msel {} { + global posted + set posted 0 +} + +bind .i { pressed %b %X %Y } + +#----- specifics ----- + +.i configure -image ims +.m1 add command -command { msel; puts hi } -label hi +.m3 add command -command { msel; puts boo } -label boo + -- 2.30.2