Changeset 996 for trunk/expgui


Ignore:
Timestamp:
Aug 27, 2010 11:14:50 PM (10 years ago)
Author:
toby
Message:

Many revisions for handling file names with spaces using new SetEXPfile proc.
Use of directories with spaces for data files is probably not a problem, since we cd there, but EXP file names and install locations can be messy. Convert names on windows, where possible, and warn for now.

fix DISAGL window buttons for files with spaces.

cleanup MakeScrollTable?

allow ~/.gsas_config on Windows.

for use update.bat instead of building file as needed;

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expgui

    r995 r996  
    5050catch {if $env(EXPGUI_NOSHELL) {set expgui(shell) 0}}
    5151
     52set expgui(expfile) {}
    5253if {$argv != ""} {
    5354    if {[string match *noshell* [string tolower $argv]]} {
    5455        #puts noshell
    5556        set expgui(shell) 0
    56         set expgui(expfile) [lindex $argv 1]
     57        SetEXPfile [lindex $argv 1]
    5758    } else {
    58         set expgui(expfile) [lindex $argv 0]
     59        SetEXPfile [lindex $argv 0]
    5960    }
    6061    if {[string match -nocase {.o[0-9a-f][0-9a-f]} \
     
    6465            "At present you must use open (expnam) to open archived files" warning 0 "Continue"
    6566        set expgui(expfile) {}
    66     } elseif {[string toupper [file extension $expgui(expfile)]] != ".EXP"} {
    67         append expgui(expfile) ".EXP"
    68     }
    69 } else {
    70     set expgui(expfile) {}
     67    }
    7168}
    7269
     
    133130    set expgui(script) [file join [pwd] $expgui(script)]
    134131}
    135 set expgui(scriptdir) [file dirname $expgui(script) ]
     132# save the package installation location; fix if possible, warn later (after
     133# routines are sourced)
     134set scriptdir [
     135               set expgui(scriptdir) [file dirname $expgui(script) ]
     136               ]
     137
     138if {[string first " " $expgui(scriptdir)] != -1} {
     139    if {$tcl_platform(platform) == "windows"} {
     140        # translate to the windows 8.3 version, if supported for this drive
     141        set expgui(scriptdir) [file attributes $expgui(scriptdir) -shortname]
     142    }
     143}
    136144set expgui(gsasdir) [file dirname $expgui(scriptdir)]
    137145set expgui(gsasexe) [file join $expgui(gsasdir) exe]
     
    156164#---------------------------------------------------------------------------
    157165# override options with locally defined values
    158 set filelist [file join $expgui(scriptdir) localconfig]
     166lappend filelist [file join $expgui(scriptdir) localconfig]
    159167if {$tcl_platform(platform) == "windows"} {
    160168    lappend filelist "c:/gsas.config"
    161 } else {
    162     lappend filelist [file join ~ .gsas_config]
    163 }
     169}
     170lappend filelist [file join ~ .gsas_config]
    164171if {[catch {
    165172    foreach file $filelist {
     
    172179        -helplink "expguierr.html Customizewarning"
    173180}
     181# warn/stop on spaces in install location
     182if {[string first " " $scriptdir] != -1} {
     183    if {$tcl_platform(platform) == "windows"} {
     184        # did the translation it work?
     185        if {[string first " " $expgui(scriptdir)] != -1} {
     186            update
     187            MyMessageBox -parent . -title "Spaces in path" \
     188                -message "You are using an install directory with a space in the name ($scriptdir) that on Windows that does not have a corresponding DOS name. Is this on a networked drive? This install location will not work for EXPGUI. Sorry." \
     189                -icon warning -type Quit -default quit
     190            exit
     191        }
     192    }
     193    set warn 1
     194    catch {set warn $expgui(warnonscriptspace)}
     195    if $warn {
     196        update
     197        MyMessageBox -parent . -title "Good luck..." \
     198            -message "You are using an install directory with a space in the name ($scriptdir) -- You may encounter bugs in EXPGUI that I am trying to fix. If so, please e-mail enough detail to Brian.Toby@ANL.gov so that I can try to reproduce it." \
     199            -icon warning -type Continue -default continue
     200        set expgui(warnonscriptspace) 0
     201    }
     202}
     203
    174204if [catch {package require BWidget}] {
    175205    set msg "Error loading the BWidget package: This should not happen if you use the version of Tcl/Tk (tcl84+.exe) distributed with EXPGUI"
     
    269299}
    270300#---------------------------------------------------------------------------
    271 if {$expgui(expfile) != ""} {
    272    # is there a space in the EXP name?
    273     if {[string first " " [file tail $expgui(expfile)]] != -1} {
    274         update
    275         MyMessageBox -parent . -title "File Name Error" \
    276                 -message "File name \"$expgui(expfile)\" is invalid -- EXPGUI cannot process experiment files with spaces in the name" \
    277                 -icon warning -type Continue -default continue
    278 #               -helplink "expguierr.html OpenErr"
    279         set expgui(expfile) {}
    280         set expgui(resize) 1
    281     } elseif {[string first " " [file dirname $expgui(expfile)]] != -1} {
    282         update
    283         MyMessageBox -parent . -title "Good luck..." \
    284             -message "You are using a directory with a space in the name ([file dirname $expgui(expfile)]) -- You may encounter bugs in EXPGUI, which are being corrected as reported. Please e-mail them to Brian.Toby@ANL.gov so they can be fixed." \
    285                 -icon warning -type Continue -default continue
    286 #               -helplink "expguierr.html OpenErr"
    287         set expgui(resize) 1
    288     } elseif ![file exists $expgui(expfile)] {
    289         update
    290         set ans [
    291         MyMessageBox -parent . -title "File Open Error" \
    292                 -message "File [file tail $expgui(expfile)] does not exist in [file dirname $expgui(expfile)]. OK to create?" \
    293                 -icon question -type {"Select other" "Create"} -default "select other" \
    294                 -helplink "expguierr.html OpenErr"
    295         ]
    296         if {[string tolower $ans] != "create"} {set expgui(expfile) {}}
    297         set expgui(resize) 1
    298     }
    299 }
    300301if {$expgui(expfile) == ""} {
    301302    # place the parent window because the getExpFileName window will be centered above it.
     
    310311    # I am not sure it is still needed.
    311312    update
    312     #
    313     set expgui(expfile) [getExpFileName ""]
     313    SetEXPfile [getExpFileName ""]
    314314    set expgui(resize) 1
    315315}
    316316if {$expgui(expfile) == ""} exit
    317 # you've been warned this .EXP does not exist!
    318 if ![file exists $expgui(expfile)] {
    319     # create an "empty" exp file
    320     createexp $expgui(expfile) \
    321             [getstring "title for experiment $expgui(expfile)" 60 0]
    322 }
    323 catch {cd [string trim [file dirname $expgui(expfile)]]}
    324317
    325318#
     
    330323proc loadexp {expfile} {
    331324    global expgui expmap entryvar entrycmd tcl_platform
     325    set prevexp $expgui(expfile)
    332326    # is this a compressed archive file?
    333327    if {[string match {*.O[0-9A-F][0-9A-F]} $expfile]} {
    334         set expgui(expfile) {}
    335328        set expnam [file rootname $expfile]
    336329        set ans [MyMessageBox -parent . -title "Load Archived File" \
     
    376369            set expgui(needpowpref) 2
    377370            set expgui(needpowpref_why) "\tA new .EXP file was created\n"
    378         }
    379     }
    380     set expgui(expfile) $expfile
     371            SetEXPfile $newexpfile
     372        } else {
     373            SetEXPfile $expfile
     374        }
     375        if {$expgui(expfile) == ""} {
     376            set expgui(expfile) $prevexp
     377            return
     378        }
     379    }
    381380
    382381    # change the icon and assign an app to this .EXP file
    383     global tcl_platform
    384382    if {$tcl_platform(os) == "Darwin" && $expgui(MacAssignApp)} {
    385383        MacSetResourceFork $expfile
    386384    }
    387385
     386    SetEXPfile $expfile
     387    if {$expgui(expfile) == ""} {
     388        set expgui(expfile) $prevexp
     389        return
     390    }
    388391    # read in the .EXP file
    389392    set fmt [expload $expfile]
     
    397400        set expgui(changed) 1
    398401    }
    399     # force exp files to be upper case, force save if name changes
    400     set filetail [file tail $expfile]
    401     set filetailcaps [string toupper $filetail]
    402     if {$tcl_platform(platform) == "unix" && $filetail != $filetailcaps} {
    403         set expgui(changed) 1
    404     }
    405     if {[file dirname $expfile] == "."} {
    406         set expgui(expfile) $filetailcaps
    407     } else {
    408         set expgui(expfile) [file join \
    409                 [file dirname $expfile] $filetailcaps]
    410     }
    411 
    412402    mapexp
    413403    if {$expgui(MacroRunning)} {
     
    518508proc SaveAsFile {} {
    519509    global expgui
     510    global tcl_platform
     511    set prevexp $expgui(expfile)
    520512    set newexpfile [getExpFileName new]
    521513    if {$newexpfile == ""} return
     514    SetEXPfile $newexpfile
     515    if {$expgui(expfile) == ""} {
     516        set expgui(expfile) $prevexp
     517        return
     518    }
    522519    expwrite $newexpfile
    523     set expgui(expfile) $newexpfile
    524     catch {cd [string trim [file dirname $expgui(expfile)]]}
    525520    # change the icon and assign an app to this .EXP file
    526     global tcl_platform
    527521    if {$tcl_platform(os) == "Darwin" && $expgui(MacAssignApp)} {
    528522        MacSetResourceFork $expgui(expfile)
     
    554548        }
    555549    }
     550    set prevexp $expgui(expfile)
    556551    set newexpfile [getExpFileName old]
    557552    if {$newexpfile == ""} return
     553    SetEXPfile $newexpfile
     554    if {$expgui(expfile) == ""} {
     555        set expgui(expfile) $prevexp
     556        return
     557    }
    558558
    559559    # switch to the 1st page
    560560    RaisePage lsFrame
    561 
    562     if ![file exists $newexpfile] {
    563         # you've been warned this .EXP does not exist!
    564         # create an "empty" exp file
    565         createexp $newexpfile \
    566                 [getstring "title for experiment $newexpfile" 60 0]
    567     }
    568     set expgui(expfile) $newexpfile
    569     catch {cd [string trim [file dirname $expgui(expfile)]]}
    570561    set expgui(globalmode) 0
    571562    loadexp $expgui(expfile)
     
    40744065
    40754066
    4076 
    40774067foreach num {1 2 3 4 5 6 7 8 9} {
    40784068    grid [label $expgui(FobsExtractFrame).l$num -text $num] -row 1 -column $num
     
    41394129#-------------------------------------------------------------------------
    41404130#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv THE MENU BAR vvvvvvvvvvvvvvvvvvvvvv
    4141 
    41424131#---- file menu button
    41434132menubutton $expgui(fm).file -text File -menu $expgui(fm).file.menu
Note: See TracChangeset for help on using the changeset viewer.