2 #----- general machinery -----
5 #load /home/ian/things/Systray/tktray-1.3.8/libtktray1.3.8.so
10 tktray::icon .i -class example
11 .i configure -docked 1
19 proc pressed {b x y} {
23 puts "unpost $posted toggle"
26 } elseif {[winfo exists .m$b]} {
29 puts "unpost $posted other"
42 proc setupinnerwindow {} {
43 global innerwindow_after innerwindow
44 catch { after cancel $innerwindow_after }
45 catch { unset innerwindow_after }
46 if {[info exists innerwindow]} return
48 foreach child [winfo children .i] {
49 if {![winfo exists $child]} continue
50 lappend children $child
52 if {[llength $children]==1} {
53 set innerwindow [lindex $children 0]
54 bind $innerwindow <Destroy> {
55 innerwindow-unavailable
56 catch { unset innerwindow }
57 after idle setupinnerwindow
61 after 5000 setupinnerwindow
65 bind .i <ButtonPress> { pressed %b %X %Y }
67 proc tooltip_starttimer {state x y} {
68 global tooltip_after posted tooltip_inwindow
69 if {$state || $posted || !$tooltip_inwindow} { tooltip_cancel; return }
70 catch { after cancel $tooltip_after }
71 set tooltip_after [after 500 tooltip_show $x $y]
74 proc tooltip_cancel {} {
76 catch { after cancel $tooltip_after }
77 catch { unset $tooltip_after }
81 set tooltip_inwindow 0
83 proc tooltip_enter {state x y} {
84 global tooltip_inwindow
85 set tooltip_inwindow 1
86 tooltip_starttimer $state $x $y
89 proc tooltip_leave {} {
90 global tooltip_inwindow
91 set tooltip_inwindow 0
95 proc setuptooltip {} {
96 bind .i <Enter> { tooltip_enter %s %X %Y }
97 bind .i <Leave> { tooltip_leave }
98 bind .i <ButtonRelease> { tooltip_cancel; tooltip_starttimer %s %X %Y }
99 bind .i <Motion> { tooltip_starttimer %s %X %Y }
100 toplevel .tt -background black
102 wm overrideredirect .tt 1
103 label .tt.t -justify left -background {#EEE1B3}
104 pack .tt.t -padx 1 -pady 1
108 proc settooltip {s} {
109 .tt.t configure -text $s
112 proc tooltip_show {x y} {
115 wm geometry .tt +$x+$y
119 proc setimage {image} {
120 .i configure -image $image