chiark / gitweb /
an applet
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 Jan 2012 01:49:17 +0000 (01:49 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 Jan 2012 01:49:17 +0000 (01:49 +0000)
.gitignore [new file with mode: 0644]
example [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..b25c15b
--- /dev/null
@@ -0,0 +1 @@
+*~
diff --git a/example b/example
new file mode 100755 (executable)
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 <ButtonPress> { 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
+