1#!/bin/sh 2# the next line restarts using tclsh \ 3exec tclsh "$0" "$@" 4 5# $Id: test-progressBar.tcl,v 1.7 2004/08/12 08:17:29 baum Exp $ 6 7# ensure that "." is the decimal point 8unset -nocomplain env(LC_ALL) 9set ::env(LC_NUMERIC) "C" 10 11set auto_path [linsert $auto_path 0 [file join [file dirname [info script]] ../src]] 12package require Gnocl 13 14set noUpdates 0 15 16set left [gnocl::box -orientation vertical] 17set right [gnocl::box -orientation vertical] 18set mainBox [gnocl::box -orientation horizontal -children "$left $right"] 19 20# set pulse [gnocl::progressBar -activityMode 1 -text "Activity Mode" -showText 1] 21set fract 0 22set pulse [gnocl::progressBar -activityMode 1] 23$left add $pulse 24set bar [gnocl::progressBar] 25$left add $bar 26 27$right add [gnocl::checkButton -text "%__Visible" -active 1 \ 28 -onToggled "$bar configure -visible %v"] 29$right add [gnocl::checkButton -text "showText" -active 1 \ 30 -onToggled "$bar configure -showText %v"] 31 32set opt [gnocl::optionMenu -onChanged "$bar configure -orientation %v" \ 33 -items {leftToRight rightToLeft bottomToTop topToBottom}] 34$right add $opt 35$right add [gnocl::label -text "pulseStep"] 36$right add [gnocl::spinButton -lower 0.1 -upper 0.6 -stepInc 0.1 -digits 1 \ 37 -value 0.2 -onValueChanged "$pulse configure -pulseStep %v"] 38 39$right add [gnocl::label -text "textAlign"] 40set alignMenu [gnocl::optionMenu -onChanged "$bar configure -textAlign %v" \ 41 -items {topLeft top topRight left center right bottomLeft \ 42 bottom bottomRight "0.2 0.2" "0.2 0.8" "0.8 0.8" }] 43$right add $alignMenu 44 45 46proc doPulse { } { 47 $::pulse pulse 48 after 10 doPulse 49} 50proc doFract { } { 51 global fract 52 set fract [expr {$fract+0.05}] 53 if { $fract > 1 } { 54 set fract 0 55 } 56 $::bar configure -fraction $fract -text \ 57 [format "%.0f %%" [expr {$fract*100.}]] 58 after 10 doFract 59} 60 61proc bgerror { err } { 62 puts "in bgerror: $err" 63 puts $::errorInfo 64 # puts "errorCode: $::errorCode" 65} 66 67doPulse 68doFract 69 70if { $argc == 1 } { 71 set win [gnocl::plug -socketID [lindex $argv 0] -child $mainBox -onDestroy exit] 72} else { 73 set win [gnocl::window -child $mainBox -onDestroy exit] 74} 75 76gnocl::mainLoop 77 78