summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-10-31 16:11:49 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-10-31 16:11:49 (GMT)
commit8a7f4b4015f4c4085961568097d3e25d4b664363 (patch)
treef9264e342aa7b25da4989cb63802edda038d8eac
parent8cff39c2e6ce28a548c13c2f71f991658686e7d1 (diff)
downloadtk-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.
-rw-r--r--ChangeLog4
-rw-r--r--library/demos/image2.tcl11
2 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 96622d6..bddda72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2007-10-31 Donal K. Fellows <donal.k.fellows@manchester.ac.uk>
+ * library/demos/image2.tcl (loadImage): Mark non-loadable images
+ as such instead of throwing a nasty dialog, following suggestion
+ from Don Porter.
+
* generic/tkImgPhoto.c (Tk_PhotoPutBlock): More optimization, derived
from [Patch 224066].
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