#!/bin/sh # the next line restarts using wish\ exec wish "$0" "$@" # By Sean Lewkiw # namespace progressbar proc stolen off internet somewhere set HOME $env(HOME) set USER $env(USER) set file $HOME/.longlunch if { [string match *help* [lindex $argv 0] ] } { puts "USAGE: longlunch (Time in seconds to complete one \"frame\".)" puts "If file $file exists, the list of passes in the interace will be read from that file." exit } set timelimit 600 if { [lindex $argv 0] != "" } { set timelimit [lindex $argv 0] } set timelimit [ expr $timelimit * 10 ] option add *Progress.undoneForeground black widgetDefault option add *Progress.undoneBackground white widgetDefault option add *Progress.doneForeground white widgetDefault option add *Progress.doneBackground green4 widgetDefault option add *Progress.borderWidth 1 widgetDefault option add *Progress.relief sunken widgetDefault proc set_list {} { global list set list "World-Space-Normal-Pre-Derivative Cozinofski-Kamal-4th-Order-Oscillation Thornley-Null-Construction \ Subsurface-Inter-Data-Reflections MachIII-B-Spline-Obstruftication Transferring_Kebab_Rotation_Matrix Smeagol-DeFibulation \ Wallace-Berkenstein-Homogenus-Vector Parametric-Conjunction Matrix-Transformation \ Spectral-Tomography Spatially-Enumerated-Data-Struture \ Voxel-Rentrant-Polygon-Clipping B-Spline-Sandwiching Hemi-Cube-Algorithm \ Gottschalk-Felching-Rigid-Body-Distortion Paraboloid-Digestion-Tension-Distortion \ Seventh-Order-Quadratic-Interpolation Cornflake-Box-Moist-Inclusion Illuminance-Loop-Scanning-Pass-No \ Patch-to-Patch-Radiosity-Solution Munted-Factor-Extrapolation Totally-Random-Failure-Creation \ Duran-Duran-Random-Lyric-Generator Carnuba-Wax-Coat-Application-Layer-No Random-Noise-&-Artifact-Generator \ Adding-Pops-Ticks-Hissing Hermeneuticalizing Defenestration" } if { [ file isfile $file ] } { puts "Reading from $file." set fileout [open $file r] set list [string trim [read $fileout]] close $fileout } else { set_list } namespace eval dkfprogress { namespace export Progress SetProgress proc Progress {w args} { global call col uplevel 1 [list frame $w -class Progress] $args set call [expr $call + 1] set n [expr round(100.0 * [expr rand()])] set n [expr {$n < 0? 0: $n > 100? 100: $n}] set red [expr {$n > 75? 60 - ($n * 15 / 25) : 15}] set green [expr {$n < 50? $n * 15 / 50 : 15}] set col [format "#%01x%01x0" $red $green] #puts $col foreach {val} { undoneForeground doneForeground undoneBackground doneBackground } { set class [string toupper [string index $val 0]\ ][string range $val 1 end] set $val [option get $w $val $class] } set varname [namespace current]::progressPercent($w) frame $w.l -borderwidth 0 -background $undoneBackground -width 400 label $w.l.l -textvariable $varname -borderwidth 0 \ -foreground $undoneForeground -background $undoneBackground $w.l configure -height [expr {int([winfo reqheight $w.l.l]+2)}] frame $w.l.fill -background $col label $w.l.fill.l -textvariable $varname -borderwidth 0 \ -foreground $doneForeground -background $doneBackground bind $w.l [namespace code [list ProgressConf $w "%w"]] pack $w.l -fill both -expand 1 place $w.l.l -relx 0.5 -rely 0.5 -anchor center place $w.l.fill -x 0 -y 0 -relheight 1 -relwidth 0 place $w.l.fill.l -x 0 -rely 0.5 -anchor center SetProgress $w 0 return $w } proc ProgressConf {w width} { place conf $w.l.fill.l -x [expr {int($width/2)}] } proc SetProgress {win value {range 100}} { set progress [expr {int(100*$value)/int($range)}] set relwidth [expr {double($value)/double($range)}] variable progressPercent place conf $win.l.fill -relwidth $relwidth set progressPercent($win) "${progress}%" } } namespace import dkfprogress::Progress dkfprogress::SetProgress # ---------------------------------------------------------------------- proc timer {win limit delay {value 0}} { global db SetProgress .${win} $value $limit incr value if {$value >= $limit} { set value 0 set db(${win},0) [expr $db(${win},0) + 1] .${win}count configure -text $db(${win},0) } after $delay [list timer ${win} $limit $delay $value] } label .label1 -text "Function" label .label2 -text "Pass" label .label3 -text "Progress" grid .label1 -row 0 -column 0 -sticky ew grid .label2 -row 0 -column 1 -sticky ew grid .label3 -row 0 -column 2 -sticky ew set call 1 set count 1 foreach i $list { set b [string tolower $i] set z [regsub -all "_" ${i} " " foo ] label .${b}label -text "${foo}:" -relief groove -width 55 label .${b}count -text 1 -relief groove set db(${b},0) 1 grid .${b}label -row $count -column 0 -sticky e grid .${b}count -row $count -column 1 -sticky w grid [Progress .$b] -row $count -column 2 -sticky ew #timer $b 100 timer $b [expr round(100.0 + [expr rand() * 20 ])] [expr round(500.0 * [expr rand()])] incr count } set i "Frame_Number" set b [string tolower $i] label .${b}label -text "${i}:" -relief raised -width 55 label .${b}count -text 1 -relief groove set db(${b},0) 1 grid .${b}label -row $count -column 0 -sticky e -pady 15 grid .${b}count -row $count -column 1 -sticky w grid [Progress .$b] -row $count -column 2 -sticky ew timer $b 100 $timelimit wm title . "Pre-Render Data Accumulation"