diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-10-31 16:11:49 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-10-31 16:11:49 (GMT) |
commit | 8a7f4b4015f4c4085961568097d3e25d4b664363 (patch) | |
tree | f9264e342aa7b25da4989cb63802edda038d8eac /library | |
parent | 8cff39c2e6ce28a548c13c2f71f991658686e7d1 (diff) | |
download | tk-8a7f4b4015f4c4085961568097d3e25d4b664363.zip tk-8a7f4b4015f4c4085961568097d3e25d4b664363.tar.gz tk-8a7f4b4015f4c4085961568097d3e25d4b664363.tar.bz2 |
Mark non-loadable images as such instead of throwing a nasty dialog,
following suggestion from Don Porter.
Diffstat (limited to 'library')
-rw-r--r-- | library/demos/image2.tcl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/library/demos/image2.tcl b/library/demos/image2.tcl index 916551e..0aed1f5 100644 --- a/library/demos/image2.tcl +++ b/library/demos/image2.tcl @@ -3,7 +3,7 @@ # This demonstration script creates a simple collection of widgets # that allow you to select and view images in a Tk label. # -# RCS: @(#) $Id: image2.tcl,v 1.9 2004/12/21 11:56:35 dkf Exp $ +# RCS: @(#) $Id: image2.tcl,v 1.10 2007/10/31 16:11:49 dkf Exp $ if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo." @@ -22,7 +22,7 @@ proc loadDir w { global dirName $w.f.list delete 0 end - foreach i [lsort [glob -directory $dirName *]] { + foreach i [lsort [glob -type f -directory $dirName *]] { $w.f.list insert end [file tail $i] } } @@ -57,7 +57,12 @@ proc loadImage {w x y} { global dirName set file [file join $dirName [$w.f.list get @$x,$y]] - image2a configure -file $file + if {[catch { + image2a configure -file $file + }]} then { + # Mark the file as not loadable + $w.f.list itemconfigure @$x,$y -bg \#c00000 -selectbackground \#ff0000 + } } set w .image2 |