Changeset 1527 for trunk/gui/scripts/numberentry.tcl
- Timestamp:
- Jun 22, 2009, 12:38:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/numberentry.tcl
r1342 r1527 43 43 itcl::body Rappture::NumberEntry::constructor {owner path args} { 44 44 if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} { 45 45 error "bad object \"$owner\": should be Rappture::ControlOwner" 46 46 } 47 47 set _owner $owner … … 53 53 set presets "" 54 54 foreach pre [$_owner xml children -type preset $path] { 55 56 57 55 lappend presets \ 56 [$_owner xml get $path.$pre.value] \ 57 [$_owner xml get $path.$pre.label] 58 58 } 59 59 … … 61 61 set units [$_owner xml get $path.units] 62 62 if {$units != ""} { 63 64 65 66 63 set desc [Rappture::Units::description $units] 64 if {[string match temperature* $desc]} { 65 set class Rappture::TemperatureGauge 66 } 67 67 } 68 68 … … 72 72 # 73 73 itk_component add gauge { 74 74 $class $itk_interior.gauge -units $units -presets $presets 75 75 } 76 76 pack $itk_component(gauge) -expand yes -fill both … … 84 84 85 85 if {$class == "Rappture::Gauge" && "" != $min && "" != $max} { 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 86 set color [$_owner xml get $path.about.color] 87 if {$color == ""} { 88 # deprecated. Color should be in "about" 89 set color [$_owner xml get $path.color] 90 } 91 if {$color != ""} { 92 if {$units != ""} { 93 set min [Rappture::Units::convert $min -to $units -units off] 94 set max [Rappture::Units::convert $max -to $units -units off] 95 } 96 # For compatibility. If only one color use white for min 97 if {[llength $color] == 1} { 98 set color [list $min white $max $color] 99 } 100 $itk_component(gauge) configure \ 101 -spectrum [Rappture::Spectrum ::#auto $color -units $units] 102 } 103 103 } 104 104 … … 106 106 set str [$_owner xml get $path.about.icon] 107 107 if {$str != ""} { 108 108 $itk_component(gauge) configure -image [image create photo -data $str] 109 109 } 110 110 … … 131 131 set i [lsearch -exact $args -check] 132 132 if {$i >= 0} { 133 134 133 set onlycheck 1 134 set args [lreplace $args $i $i] 135 135 } 136 136 137 137 if {[llength $args] == 1} { 138 139 140 141 142 143 144 138 if {$onlycheck} { 139 # someday we may add validation... 140 return 141 } 142 set newval [lindex $args 0] 143 $itk_component(gauge) value $newval 144 return $newval 145 145 146 146 } elseif {[llength $args] != 0} { 147 147 error "wrong # args: should be \"value ?-check? ?newval?\"" 148 148 } 149 149 … … 163 163 set label [$_owner xml get $_path.about.label] 164 164 if {"" == $label} { 165 165 set label "Number" 166 166 } 167 167 return $label … … 184 184 185 185 if {$units != "" || $min != "" || $max != ""} { 186 187 188 189 190 191 192 193 194 195 196 197 198 199 186 append str "\n\nEnter a number" 187 188 if {$min != "" && $max != ""} { 189 append str " between $min and $max" 190 } elseif {$min != ""} { 191 append str " greater than $min" 192 } elseif {$max != ""} { 193 append str " less than $max" 194 } 195 196 if {$units != ""} { 197 set desc [Rappture::Units::description $units] 198 append str " with units of $desc" 199 } 200 200 } 201 201 return [string trim $str] … … 218 218 set valid {normal disabled} 219 219 if {[lsearch -exact $valid $itk_option(-state)] < 0} { 220 220 error "bad value \"$itk_option(-state)\": should be [join $valid {, }]" 221 221 } 222 222 $itk_component(gauge) configure -state $itk_option(-state)
Note: See TracChangeset
for help on using the changeset viewer.