#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"

#
# showpics: display all bitmap icons (xbm,xpm,gif) in a scrollable window
#

if {$argv==""} {
  set files [concat [lsort [glob -nocomplain -- {*.gif}]] \
                    [lsort [glob -nocomplain -- {*.xpm}]] \
                    [lsort [glob -nocomplain -- {*.xbm}]]]
} else {
  set files $argv
}
canvas .c -yscrollcommand ".s set" -height 200
scrollbar .s -command ".c yview"
pack .s -side right -fill y
pack .c -side left -expand yes -fill both
frame .c.f
.c create window 0 0 -anchor nw -window .c.f

set i 0
foreach f $files {
  set type ""
  case [string tolower [file extension $f]] {
    {.xbm} {set type bitmap}
    {.xpm} {set type photo}
    {.gif} {set type photo}
  }
  if {$type!=""} {
    set img [string tolower [file tail [file rootname $f]]]
    image create $type $img -file $f
  
    set f .c.f.f$i
    frame $f
    button $f.b -image $img
    label $f.l -text $img
    pack $f -fill x
    pack $f.b -side left
    pack $f.l -side right
    incr i
  }
}
update
.c config -width [winfo width .c.f]
.c config -scrollregion "0 0 0 [winfo height .c.f]"
focus .s



syntax highlighted by Code2HTML, v. 0.9.1