Debian Codegraph @

demos/hierbox3.tcl

raw
1 #!../src/bltwish
2
3 package require BLT
4 # --------------------------------------------------------------------------
5 # Starting with Tcl 8.x, the BLT commands are stored in their own
6 # namespace called "blt". The idea is to prevent name clashes with
7 # Tcl commands and variables from other packages, such as a "table"
8 # command in two different packages.
9 #
10 # You can access the BLT commands in a couple of ways. You can prefix
11 # all the BLT commands with the namespace qualifier "blt::"
12 #
13 # blt::graph .g
14 # blt::table . .g -resize both
15 #
16 # or you can import all the command into the global namespace.
17 #
18 # namespace import blt::*
19 # graph .g
20 # table . .g -resize both
21 #
22 # --------------------------------------------------------------------------
23 if { $tcl_version >= 8.0 } {
24 namespace import blt::*
25 namespace import -force blt::tile::*
26 }
27 source scripts/demo.tcl
28
29 proc AddDirEntries { w dir } {
30 if { [file isdirectory $dir] } {
31 set files [glob -nocomplain $dir/*]
32 eval $w insert end [lsort $files]
33 set subdirs [glob -nocomplain $dir/*/]
34 eval $w entry configure [lsort $subdirs] -button yes
35 }
36 }
37
38 set imageList {}
39 foreach f [glob ./images/mini-*.gif] {
40 lappend imageList [image create photo -file $f]
41 }
42
43 image create photo openFolder -file images/open.gif
44 image create photo closeFolder -file images/close.gif
45 option add *Hierbox.icons "closeFolder openFolder"
46
47 #option add *Hierbox.openCommand { AddDirEntries %W "$top/%P" }
48 #option add *Hierbox.closeCommand { eval %W delete %n 0 end }
49
50 hierbox .h \
51 -allowduplicates no \
52 -hideroot yes \
53 -yscrollcommand { .vs set } \
54 -xscrollcommand { .hs set }
55
56 scrollbar .vs -orient vertical -command { .h yview }
57 scrollbar .hs -orient horizontal -command { .h xview }
58 button .test -text Test -command {
59 set index [.h curselection]
60 set names [eval .h get -full $index]
61 puts "selected names are $names"
62 }
63
64 table . \
65 0,0 .h -fill both \
66 0,1 .vs -fill y \
67 1,0 .hs -fill x \
68
69 table configure . c1 r1 r2 -resize none
70
71 set top ../
72 .h configure -separator "/" -trim $top -autocreate yes
73 #.h entry configure 0 -label [file tail $top]
74
75 catch { exec du $top } files
76 foreach f [split $files \n ] {
77 .h insert end [lindex $f 1] -text [lindex $f 0] -button auto
78 }
79
80 focus .h