Changeset 9 for trunk/gui/apps


Ignore:
Timestamp:
Apr 19, 2005, 8:06:13 PM (19 years ago)
Author:
mmc
Message:

Massive changes across the entire toolkit. Rearranged the
XML description to agree better with new documentation and
conventions.

Added a small start of Rappture.interface and Rappture.number
in the python directory. This is the new way of doing Rappture--
by declaring variables directly in the program, not using XML
directly at all.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/apps/driver

    r8 r9  
    2727package require Rappture
    2828
    29 option add *MainWin.mode web startupFile
     29option add *MainWin.mode desktop startupFile
    3030option add *MainWin.borderWidth 0 startupFile
    3131option add *MainWin.anchor center startupFile
     
    4141option add *MainWin.bgScript "" startupFile
    4242option add *MainWin.bgColor white startupFile
     43option add *Tooltip.background white
    4344
    4445image create photo in2out \
     
    124125Rappture::MainWin .main -borderwidth 0
    125126
    126 #.main configure -title [$config get title]
     127.main configure -title [$config get title]
    127128
    128129# build everything inside this main window
     
    203204# HOOK UP ANY CONTROLS CALLED OUT IN CONFIG.XML
    204205# ----------------------------------------------------------------------
    205 foreach access [$config children -type access controls] {
    206     set name [$config get controls.$access]
    207     switch -glob -- $name {
    208         parameters.ambient* - structure* {
    209 ##            $win.input.device controls add $name
    210         }
    211     }
    212 }
     206proc controls_add {container libObj path} {
     207    set presets ""
     208    foreach pre [$libObj children -type preset $path] {
     209        lappend presets \
     210            [$libObj get $path.$pre.value] \
     211            [$libObj get $path.$pre.label]
     212    }
     213
     214    set type Rappture::Gauge
     215    set units [$libObj get $path.units]
     216    if {$units != ""} {
     217        set desc [Rappture::Units::description $units]
     218        if {[string match temperature* $desc]} {
     219            set type Rappture::TemperatureGauge
     220        }
     221    }
     222
     223    set counter 0
     224    set w "$container.gauge[incr counter]"
     225    while {[winfo exists $w]} {
     226        set w "$container.gauge[incr counter]"
     227    }
     228
     229    # create the widget
     230    $type $w -units $units -presets $presets
     231    pack $w -side top -anchor w
     232#    bind $w <<Value>> [itcl::code $this _controlSet $w $libObj $path]
     233
     234    set min [$libObj get $path.min]
     235    if {"" != $min} { $w configure -minvalue $min }
     236
     237    set max [$libObj get $path.max]
     238    if {"" != $max} { $w configure -maxvalue $max }
     239
     240    set str [$libObj get $path.default]
     241    if {$str != ""} { $w value $str }
     242
     243    if {$type == "Rappture::Gauge" && "" != $min && "" != $max} {
     244        set color [$libObj get $path.color]
     245        if {$color == ""} {
     246            set color blue
     247        }
     248        if {$units != ""} {
     249            set min [Rappture::Units::convert $min -to $units -units off]
     250            set max [Rappture::Units::convert $max -to $units -units off]
     251        }
     252        $w configure -spectrum [Rappture::Spectrum ::#auto [list \
     253            $min white $max $color] -units $units]
     254    }
     255
     256    set str [$libObj get $path.label]
     257    if {$str != ""} {
     258        set help [$libObj get $path.help]
     259        if {"" != $help} {
     260            append str "\n$help"
     261        }
     262        if {$units != ""} {
     263            set desc [Rappture::Units::description $units]
     264            append str "\n(units of $desc)"
     265        }
     266        Rappture::Tooltip::for $w $str
     267    }
     268
     269    set str [$libObj get $path.icon]
     270    if {$str != ""} {
     271        $w configure -image [image create photo -data $str]
     272    }
     273}
     274
     275if {[winfo exists $win.input.device]} {
     276    foreach access [$config children -type access controls] {
     277        set name [$config get controls.$access]
     278        switch -glob -- $name {
     279            input.(ambient)* - structure* {
     280                $win.input.device controls add $name
     281            }
     282        }
     283    }
     284} else {
     285    foreach access [$config children -type access controls] {
     286        set name [$config get controls.$access]
     287        controls_add $win.input $tool $name
     288    }
     289    $w.analyze simulate
     290}
Note: See TracChangeset for help on using the changeset viewer.