################################################################ # proc showFolder {dir}-- # Display the contents of a folder in a GUI # Arguments # dir The directory to display # # Results # GUI is modified. # proc showFolder {dir} { destroy {*}[winfo children .] cd $dir set winNum 0 set row 0 set col 0 set w [button .b[incr winNum] -text up -foreground red \ -command "showFolder .."] grid $w -row $row -column $col incr col foreach name [glob *] { if {[file type $name] eq "file"} { set w [label .l[incr winNum] -text $name -foreground blue] } elseif {[file type $name] eq "directory"} { set w [button .b[incr winNum] -text $name -foreground red \ -command "showFolder $name"] } else { set w [label .l[incr winNum] -text $name -foreground black] } grid $w -row $row -column $col incr col if {$col > 4} { set col 0 incr row } } } # Change /etc/mail to a folder on your system that has files and subfolders. # /Volumes/Scratch is good on the Lab Macs # "C:/Documents and Folders/All/Documents" is good on a Windows XP box. # showFolder /etc/mail