Tk Library Source Code

Artifact [ff5c30ed7b]
Login

Artifact ff5c30ed7b093fd0698a27462618cd477017934c:

Attachment "image.tcl" to ticket [554233ffff] added by davesnyd 2002-05-10 02:49:05.
#!/bin/sh
################################################################################
# tcl magic restart \
exec wish8.3 "$0" --  "$@"

proc dispImgSet {ext type} {
	global i 

	if { ! [info exists i] } { set i 0 }
	set j 1

	set utype [string toupper $type]

	set globlist [lsort [glob -nocomplain *.$ext] ]
	if { [llength $globlist] == 0 } {
		set hdr "No images of type $utype"
	} else {	
		set hdr "Displaying images of type $utype:"
	}	
	label .title$i -text $hdr
	grid .title$i -sticky ew -pady 10 -row $i -columnspan 2

	foreach file $globlist {
		incr i
		if { [catch {image create $type -file $file} img($i)] } {
			incr i -1
			continue
		}	
		label .lbl$i -text "$utype $j from file $file:"
		label .img$i -image $img($i)
		grid .lbl$i -padx 10 -sticky w -column 0 -row $i 
		grid .img$i -padx 10 -sticky ew -column 1 -row $i
		incr j
	}	

	incr i
	
}	

wm withdraw .
wm title . "Display images"
wm resizable . 0 0

dispImgSet gif photo
dispImgSet xbm bitmap
button .b1 -text "Exit" -command exit
grid .b1  -pady 20 -columnspan 2

wm deiconify .