Changeset 3854


Ignore:
Timestamp:
Aug 6, 2013, 6:49:30 AM (11 years ago)
Author:
gah
Message:

add search path for image files in pictures in drawings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/scripts/drawingentry.tcl

    r3765 r3854  
    583583    if { [string compare -length 7 $contents "file://"] == 0 } {
    584584        set fileName [string range $contents 7 end]
    585         if { [file exists $fileName] } {
    586             set img [image create photo -file $fileName]
     585        set path $fileName
     586        # find the file on a search path
     587        if { [file pathtype $path] != "absolute" } {
     588            set dir [[$_owner tool] installdir]
     589            set searchlist [list $dir [file join $dir docs]]
     590            foreach dir $searchlist {
     591                if {[file readable [file join $dir $fileName]]} {
     592                    set path [file join $dir $fileName]
     593                    break
     594                }
     595            }
     596        }
     597        if { [file exists $path] } {
     598            set img [image create photo -file $path]
    587599        } else {
    588             puts stderr "WARNING: can't find picture contents \"$fileName\""
     600            puts stderr "WARNING: can't find picture contents \"$path\""
    589601        }
    590602    } elseif { [string compare -length 7 $contents "http://"] == 0 } {
Note: See TracChangeset for help on using the changeset viewer.