diff options
Diffstat (limited to 'library/demos/image2.tcl')
-rw-r--r-- | library/demos/image2.tcl | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/library/demos/image2.tcl b/library/demos/image2.tcl index 67560b3..7b3d748 100644 --- a/library/demos/image2.tcl +++ b/library/demos/image2.tcl @@ -7,6 +7,8 @@ if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo." } +package require Tk + # loadDir -- # This procedure reloads the directory listbox from the directory # named in the demo's entry. @@ -18,7 +20,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] } } @@ -53,7 +55,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 @@ -66,17 +73,16 @@ positionWindow $w label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration allows you to view images using a Tk \"photo\" image. First type a directory name in the listbox, then type Return to load the directory into the listbox. Then double-click on a file name in the listbox to see that image." pack $w.msg -side top -frame $w.buttons -pack $w.buttons -side bottom -fill x -pady 2m -button $w.buttons.dismiss -text Dismiss -command "destroy $w" -button $w.buttons.code -text "See Code" -command "showCode $w" -pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x frame $w.mid pack $w.mid -fill both -expand 1 labelframe $w.dir -text "Directory:" -set dirName [file join $tk_library demos images] +# Main widget program sets variable tk_demoDirectory +set dirName [file join $tk_demoDirectory images] entry $w.dir.e -width 30 -textvariable dirName button $w.dir.b -pady 0 -padx 2m -text "Select Dir." \ -command "selectAndLoadDir $w" |