Changeset 3513 for trunk/gui/scripts


Ignore:
Timestamp:
Mar 16, 2013, 12:28:44 PM (12 years ago)
Author:
gah
Message:

Add string trim to select 'xml get' calls

Location:
trunk/gui/scripts
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/analyzer.tcl

    r3330 r3513  
    355355
    356356    # tool can run on "manual" (default) or "auto"
    357     set cntl [$tool xml get tool.control]
     357    set cntl [string trim [$tool xml get tool.control]]
    358358    if {"" == $cntl} {
    359         set cntl [$tool xml get tool.control.type]
     359        set cntl [string trim [$tool xml get tool.control.type]]
    360360    }
    361361    if {"" != $cntl} {
     
    503503itcl::body Rappture::Analyzer::load {xmlobj} {
    504504    # only show the last result? then clear first
    505     if {[$_tool xml get tool.analyzer] == "last"} {
     505    if {[string trim [$_tool xml get tool.analyzer]] == "last"} {
    506506        clear
    507507    }
  • trunk/gui/scripts/booleanentry.tcl

    r3330 r3513  
    5555
    5656    # if the control has an icon, plug it in
    57     set icon [$_owner xml get $path.about.icon]
     57    set icon [string trim [$_owner xml get $path.about.icon]]
    5858    if {$icon != ""} {
    5959        itk_component add icon {
     
    8080            -interactcommand [itcl::code $this _log]
    8181    }
    82     set color [$_owner xml get $path.about.color]
     82    set color [string trim [$_owner xml get $path.about.color]]
    8383    if {$color != ""} {
    8484        $itk_component(switch) configure -oncolor $color
     
    9393    # Assign the default value to this widget, if there is one.
    9494    #
    95     set str [$_owner xml get $path.default]
     95    set str [string trim [$_owner xml get $path.default]]
    9696    if {"" != $str} {
    9797        $itk_component(switch) value $str
  • trunk/gui/scripts/choiceentry.tcl

    r3330 r3513  
    193193                $_owner notify add $this $cntl [itcl::code $this _rebuild]
    194194
    195                 set label [string trim [$_owner xml get $_path.$cname.about.label]]
     195                set label [$_owner xml get $_path.$cname.about.label]
    196196                if {"" == $label} {
    197197                    set label "%type #%n"
     
    226226            #
    227227            set val [string trim [$_owner xml get $_path.$cname.value]]
    228             set str [string trim [$_owner xml get $_path.$cname.about.label]]
     228            set str [$_owner xml get $_path.$cname.about.label]
    229229            if {"" == $val} {
    230230                set val $str
     
    276276# ----------------------------------------------------------------------
    277277itcl::body Rappture::ChoiceEntry::_tooltip {} {
    278     set tip [string trim [$_owner xml get $_path.about.description]]
     278    set tip [$_owner xml get $_path.about.description]
    279279
    280280    # get the description for the current choice, if there is one
  • trunk/gui/scripts/controls.tcl

    r3330 r3513  
    169169        }
    170170        control {
    171             set label [$_owner xml get $path.label]
    172             if {"" == $label} { set label "Simulate" }
    173             set service [$_owner xml get $path.service]
     171            set label [string trim [$_owner xml get $path.label]]
     172            if {"" == $label} {
     173                set label "Simulate"
     174            }
     175            set service [string trim [$_owner xml get $path.service]]
    174176            button $w -text $label -command [list $service run]
    175177        }
     
    266268    set _name2info($name-enable) $enable
    267269
    268     set hidden [$_owner xml get $_name2info($name-path).hide]
     270    set hidden [string trim [$_owner xml get $_name2info($name-path).hide]]
    269271    if { $hidden != "" } {
    270272        set _name2info($name-enable) [expr !$hidden]
  • trunk/gui/scripts/imageentry.tcl

    r3330 r3513  
    108108    }
    109109
     110    # Don't trim this string.  It make be important.
    110111    set str [$_owner xml get $path.current]
    111112    if {[string length $str] == 0} {
     
    174175    #
    175176    set bytes $_data
    176     set fmt [$_owner xml get $_path.convert]
     177    set fmt [string trim [$_owner xml get $_path.convert]]
    177178    if {"" != $fmt && "" != $_imh} {
    178179        if {"pgm" == $fmt} { set fmt "ppm -grayscale" }
  • trunk/gui/scripts/integerentry.tcl

    r3330 r3513  
    6060
    6161    # if there are min/max values, plug them in.
    62     set min [$_owner xml get $path.min]
     62    set min [string trim [$_owner xml get $path.min]]
    6363    if {"" != $min} {
    6464        $itk_component(spinner) configure -minvalue $min
    6565    }
    6666
    67     set max [$_owner xml get $path.max]
     67    set max [string trim [$_owner xml get $path.max]]
    6868    if {"" != $max} {
    6969        $itk_component(spinner) configure -maxvalue $max
     
    7171
    7272    # if there is a color, use it for the min/max spectrum
    73     set color [$_owner xml get $path.about.color]
     73    set color [string trim [$_owner xml get $path.about.color]]
    7474    if {$color != "" && $min != "" && $max != ""} {
    7575        # For compatibility. If only one color use white for min
     
    7878        }
    7979        $itk_component(spinner) configure \
    80             -spectrum [Rappture::Spectrum ::#auto $color]
     80            -spectrum [Rappture::Spectrum ::\#auto $color]
    8181    }
    8282
    8383    # if the control has an icon, plug it in
    84     set str [$_owner xml get $path.about.icon]
     84    set str [string trim [$_owner xml get $path.about.icon]]
    8585    if {$str != ""} {
    8686        $itk_component(spinner) configure -image \
     
    9393    # Assign the default value to this widget, if there is one.
    9494    #
    95     set str [$_owner xml get $path.default]
    96     if {"" != $str != ""} { $itk_component(spinner) value $str }
     95    set str [string trim [$_owner xml get $path.default]]
     96    if {"" != $str != ""} {
     97        $itk_component(spinner) value $str
     98    }
    9799}
    98100
     
    158160    set str [$_owner xml get $_path.about.description]
    159161
    160     set min [$_owner xml get $_path.min]
    161     set max [$_owner xml get $_path.max]
     162    set min [string trim [$_owner xml get $_path.min]]
     163    set max [string trim [$_owner xml get $_path.max]]
    162164
    163165    if {$min != "" || $max != ""} {
  • trunk/gui/scripts/loader.tcl

    r3512 r3513  
    303303# ----------------------------------------------------------------------
    304304itcl::body Rappture::Loader::label {} {
    305     set label [$_owner xml get $_path.about.label]
     305    set label [string trim [$_owner xml get $_path.about.label]]
    306306    if {"" == $label} {
    307307        set label "Example"
  • trunk/gui/scripts/main.tcl

    r3330 r3513  
    159159# automatic ticket submission for job failures
    160160# ----------------------------------------------------------------------
    161 set val [$tool xml get tool.reportJobFailures]
     161set val [string trim [$tool xml get tool.reportJobFailures]]
    162162if { "" != $val} {
    163163    if {[catch {Rappture::bugreport::shouldReport jobfailures $val} result]} {
     
    256256
    257257foreach comp $phases {
    258     set title [$tool xml get $comp.about.label]
     258    set title [string trim [$tool xml get $comp.about.label]]
    259259    if {$title == ""} {
    260260        set title "Input #auto"
     
    323323        }
    324324    }
    325     set type [$tool xml get tool.control]
     325    set type [string trim [$tool xml get tool.control]]
    326326    if {$type == ""} {
    327         set type [$tool xml get tool.control.type]
     327        set type [string trim [$tool xml get tool.control.type]]
    328328    }
    329329    set arrangement [$win.pager cget -arrangement]
  • trunk/gui/scripts/note.tcl

    r3330 r3513  
    6969    eval itk_initialize $args
    7070
    71     _setContents [$_owner xml get $_path.contents]
    72     set w [$_owner xml get $_path.width]
     71    _setContents [string trim [$_owner xml get $_path.contents]]
     72    set w [string trim [$_owner xml get $_path.width]]
    7373    if { $w != "" } {
    7474        $itk_component(html) configure -width $w
    7575    }
    76     set h [$_owner xml get $_path.height]
     76    set h [string trim [$_owner xml get $_path.height]]
    7777    if { $h != "" } {
    7878        $itk_component(html) configure -height $h
  • trunk/gui/scripts/periodicelemententry.tcl

    r3330 r3513  
    5252
    5353    set defval [string trim [$_owner xml get $_path.default]]
     54    # Active and inactive are lists.  Don't need to trim.
    5455    set active [$_owner xml get $_path.active]
    5556    set inactive [$_owner xml get $_path.inactive]
     
    114115    # Query the value and return.
    115116    #
    116     set how [$_owner xml get $_path.returnvalue]
     117    set how [string trim [$_owner xml get $_path.returnvalue]]
    117118    switch -- $how {
    118119        weight - number - name - symbol - all {
     
    134135# ----------------------------------------------------------------------
    135136itcl::body Rappture::PeriodicElementEntry::label {} {
    136     set label [$_owner xml get $_path.about.label]
     137    set label [string trim [$_owner xml get $_path.about.label]]
    137138    if {"" == $label} {
    138139        set label "Element"
     
    172173# ----------------------------------------------------------------------
    173174itcl::body Rappture::PeriodicElementEntry::_tooltip {} {
    174     set tip [string trim [$_owner xml get $_path.about.description]]
     175    set tip [$_owner xml get $_path.about.description]
    175176
    176177    # get the description for the current element, if there is one
  • trunk/gui/scripts/service.tcl

    r3330 r3513  
    5454    # Load up the tool description from the <interface> file.
    5555    #
    56     set intf [$_owner xml get $path.interface]
     56    set intf [string trim [$_owner xml get $path.interface]]
    5757    if {"" == $intf} {
    5858        puts "can't find <interface> description for tool at $path"
     
    6363        set xmlobj [Rappture::library $intf]
    6464        set installdir [file dirname $intf]
    65         set _tool [Rappture::Tool ::#auto $xmlobj $installdir]
    66         set _control [$_tool xml get tool.control]
     65        set _tool [Rappture::Tool ::\#auto $xmlobj $installdir]
     66        set _control [string trim [$_tool xml get tool.control]]
    6767
    6868        #
     
    8383                set ppath $path.$dir.$cname
    8484
    85                 set spath [$_owner xml get $ppath.path]
     85                set spath [string trim [$_owner xml get $ppath.path]]
    8686                if {"" == $spath} {
    8787                    error "missing <path> at $ppath"
     
    9292                  show {
    9393puts "show: $spath"
    94                     set tpath [$_owner xml get $ppath.to]
    95                     if {"" == $tpath && $dir == "input"} {
    96                         error "missing <to> at $ppath"
    97                     }
    98                     set obj [$_tool xml element -as object $spath]
    99 puts " => $obj"
    100                     lappend _show($dir) $obj
    101                     set _obj2path($obj) $spath
    102 
    103                     if {$dir == "input"} {
    104 puts "link: $tpath => $spath"
    105                         $_owner notify add $this $tpath \
    106                             [itcl::code $this _link $tpath $spath]
    107                     }
     94                      set tpath [string trim [$_owner xml get $ppath.to]]
     95                      if {"" == $tpath && $dir == "input"} {
     96                          error "missing <to> at $ppath"
     97                      }
     98                      set obj [$_tool xml element -as object $spath]
     99                      puts " => $obj"
     100                      lappend _show($dir) $obj
     101                      set _obj2path($obj) $spath
     102                     
     103                      if {$dir == "input"} {
     104                          puts "link: $tpath => $spath"
     105                          $_owner notify add $this $tpath \
     106                              [itcl::code $this _link $tpath $spath]
     107                      }
    108108                  }
    109109                  link {
    110                     set tpath [$_owner xml get $ppath.to]
    111                     if {"" == $tpath} {
    112                         error "missing <to> at $ppath"
    113                     }
    114                     if {"" == [$_owner xml element $tpath]} {
    115                         error "bad <to> path \"$tpath\" at $ppath"
    116                     }
    117                     if {$dir == "input"} {
    118 puts "link: $tpath => $spath"
    119                         $_owner notify add $this $tpath \
    120                             [itcl::code $this _link $tpath $spath]
    121                     } else {
    122 puts "path2path: $spath => $tpath"
    123                         set _path2path($spath) $tpath
    124                     }
     110                      set tpath [string trim [$_owner xml get $ppath.to]]
     111                      if {"" == $tpath} {
     112                          error "missing <to> at $ppath"
     113                      }
     114                      if {"" == [$_owner xml element $tpath]} {
     115                          error "bad <to> path \"$tpath\" at $ppath"
     116                      }
     117                      if {$dir == "input"} {
     118                          puts "link: $tpath => $spath"
     119                          $_owner notify add $this $tpath \
     120                              [itcl::code $this _link $tpath $spath]
     121                      } else {
     122                          puts "path2path: $spath => $tpath"
     123                          set _path2path($spath) $tpath
     124                      }
    125125                  }
    126                   set {
    127                     if {"" == [$_owner xml element $ppath.value]} {
     126                    set {
     127                        if {"" == [$_owner xml element $ppath.value]} {
    128128                        error "missing <value> at $ppath"
    129129                    }
  • trunk/gui/scripts/textentry.tcl

    r3330 r3513  
    8383    $_dispatcher dispatch $this !layout "[itcl::code $this _layout]; list"
    8484
    85     set _size [$_owner xml get $path.size]
    86 
    87     set hints [$_owner xml get $path.about.hints]
    88     set icon [$_owner xml get $path.about.icon]
     85    set _size [string trim [$_owner xml get $path.size]]
     86
     87    set hints [string trim [$_owner xml get $path.about.hints]]
     88    set icon [string trim [$_owner xml get $path.about.icon]]
    8989    if {[string length $icon] > 0} {
    9090        set _icon [image create photo -data $icon]
     
    103103    eval itk_initialize $args
    104104
     105    # Don't trim the text default value.  Assume that any leading/trailing
     106    # whitespace is wanted.
    105107    set str [$_owner xml get $path.default]
    106108    if {"" != $str} {
Note: See TracChangeset for help on using the changeset viewer.