Changeset 2087


Ignore:
Timestamp:
Feb 7, 2011 6:13:01 PM (13 years ago)
Author:
braffert
Message:

tester: added progress bar when running test

Location:
trunk/tester
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tester/example/fermi_broken.tcl

    r2084 r2087  
    3030
    3131# take a while and give some output along the way
     32Rappture::Utils::progress 0 -mesg "Starting..."
    3233puts "Taking a while to run..."
    33 after 2000
     34after 1000
    3435puts "making some progress"
    35 after 2000
     36after 1000
    3637puts "done"
     38Rappture::Utils::progress 10 -mesg "Starting, for real now."
     39after 1000
    3740
    3841# Label output graph with title, x-axis label,
  • trunk/tester/scripts/main.tcl

    r2086 r2087  
    171171pack $win.testrun.title -side top -anchor w
    172172
     173Rappture::Progress $win.testrun.progress
    173174button $win.testrun.abort -text "Abort"
    174175pack $win.testrun.abort -side bottom -pady {8 0}
     
    346347            # plug this object into the "Abort" button
    347348            $testrun.abort configure -command [list $testobj abort]
     349
     350            # hide progress bar
     351            pack forget $testrun.progress
    348352        }
    349353        add {
     354            set message [lindex $args 0]
     355            # scan for progress updates
     356            while {[regexp -indices \
     357                {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)} $message \
     358                 match percent mesg]} {
     359
     360                foreach {i0 i1} $percent break
     361                set percent [string range $message $i0 $i1]
     362
     363                foreach {i0 i1} $mesg break
     364                set mesg [string range $message $i0 $i1]
     365
     366                pack $testrun.progress -fill x -padx 10 -pady 10
     367                $testrun.progress settings -percent $percent -message $mesg
     368
     369                foreach {i0 i1} $match break
     370                set message [string replace $message $i0 $i1]
     371            }
     372
    350373            $testrun.scrl.info configure -state normal
    351             $testrun.scrl.info insert end [lindex $args 0]
     374            $testrun.scrl.info insert end $message
    352375
    353376            # if there are too many lines, delete some
Note: See TracChangeset for help on using the changeset viewer.