chiark / gitweb /
after hacking got it to work, needs tidying up.
[chiark-tcl-applet.git] / example
1 #!/usr/bin/wish8.4 -f
2 # -*- Tcl -*-
3
4 source applet.tcl
5
6 #----- specifics -----
7
8 .m1 add command -command { msel; puts hi } -label hi
9 .m3 add command -command { msel; puts boo } -label boo
10
11 image create bitmap ims -file gs_s.xbm   
12 #image create bitmap ims -file /usr/share/ghostscript/8.71/lib/gs_s.xbm   
13 #setimage ims
14
15 image create photo ph-dummy ;# -width 40 -height 23
16 .i configure -image ph-dummy
17 #setimage ims
18
19 setuptooltip
20 settooltip "line\nanother"
21
22 destroy [frame .i.make-exist]
23 destroy [frame .i.i.make-exist]
24
25 proc innerwindow {} {
26     puts "INNER"
27     catch { destroy .i.i.c }
28     if {![winfo exists .i.i]} return
29     destroy [frame .i.i.make-exist]
30 #    if {[catch {
31 #       .i.i configure -width [winfo width .i.i] -height [winfo height .i.i]
32 #    } emsg]} {
33 #       puts stderr $emsg...
34 #       return
35 #    }
36     frame .i.i.b -background darkblue -bd 1
37     pack .i.i.b -fill both -side left -expand 1
38     frame .i.i.b.c -container 1 -background orange ;# -width 35 -height 15
39     pack .i.i.b.c -fill both -side left -expand 1
40     puts "ID [winfo id .i.i.b.c]"
41 #    bind .i.i.b.c <Configure> iiconfigure
42 iiconfigure
43 }
44
45 proc iiconfigure {} {
46     puts IICONFIG
47     puts "IC [winfo id .i.i]"
48     set w [winfo width .i.i]
49     set h [winfo height .i.i]
50     puts "W $w H $h"
51 set w 40
52     ph-dummy configure -width $w -height 2 ;#$h
53 #    if {![string length [info command .i.i]]} {
54 #       puts NO
55 #       return
56 #    }
57 #    .i.i.b.c configure -width $w -height $h -background blue
58
59 exec /home/ian/things/Chiark-utils/chiark-utils.git/cprogs/xacpi-simple \
60         -into [winfo id .i.i.b.c] &
61 }
62
63 ##bind all <<IconCreate>> { puts sponge }
64 ##bind all <<Sping>> { puts sping%W }
65
66 #bind .i <<IconConfigure>> innerwindow
67 innerwindow
68
69 #foreach w {. .i .i.i} {
70     bind all <<IconCreate>> { puts "create %W" }
71     bind all <<IconConfigure>> { puts "config %W" }
72 #}
73
74 puts gening
75
76 #foreach ev {MapRequest ResizeRequest ConfigureRequest Create  Gravity
77 # Reparent Circulate
78 #Configure Visibility
79 #} {
80 #       bind .i <$ev> { puts "$ev => [winfo children .i]" }
81 #}
82
83 #proc report {} {
84 #       after 1000 report
85 #       puts "children: [winfo children .i]"
86 #}
87
88 #report
89
90 #after idle {
91 #      winfo children .i
92 #      frame .i.inner.c -container 1 -background yellow
93 #      pack .i.inner.c
94
95 #      after idle {
96 #           puts [winfo id .i.c]
97 #    }
98 #}