home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / tcl / examples / browse next >
Text File  |  1994-11-01  |  719b  |  39 lines

  1. #!/usr/local/bin/wish -f
  2. #
  3. # browse through specified or current directory
  4. #
  5.  
  6. listbox .list -yscroll ".scroll set" -relief raised -geometry 20x20
  7. pack .list -side left
  8. scrollbar .scroll -command ".list yview"
  9. pack .scroll -side right -fill y
  10.  
  11. if {$argc > 0} {
  12.     set dir [lindex $argv 0]
  13. } else {
  14.     set dir "."
  15. }
  16. foreach i [exec ls -a $dir] {
  17.     .list insert end $i
  18. }
  19.  
  20. bind .list <Double-Button-1> {
  21.     browse $dir [selection get]
  22. }
  23. bind .list <Control-c> {destroy .}
  24. focus .list
  25.  
  26. proc browse {dir file} {
  27.     global env
  28.     if {$dir != "."} {set file $dir/$file}
  29.     if [file isdirectory $file] {
  30.         exec browse $file &
  31.     } else {
  32.         if [file isfile $file] {
  33.             exec xedit $file &
  34.         } else {
  35.             puts stderr "can't browse $file"
  36.         }
  37.     }
  38. }
  39.