diff options
author | Nick White <git@njw.me.uk> | 2012-08-18 17:40:43 +0100 |
---|---|---|
committer | Nick White <git@njw.me.uk> | 2012-08-18 17:40:43 +0100 |
commit | d018b3d5034035caadb2f9ed1084bc44bda17620 (patch) | |
tree | c7ccd5fee5e5f52c4efe0809c45dc6f757c9ca4e /getxbookgui.tcl | |
parent | ec97e172ab11d411b3a320bcb3e57d201d459eec (diff) |
Add a progress bar to the gui
Diffstat (limited to 'getxbookgui.tcl')
-rwxr-xr-x | getxbookgui.tcl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/getxbookgui.tcl b/getxbookgui.tcl index 06cf3c7..f7135df 100755 --- a/getxbookgui.tcl +++ b/getxbookgui.tcl @@ -19,12 +19,20 @@ proc updateStatus {chan} { global dling if {![eof $chan]} { set a [gets $chan] - if { $a != "" } { .st configure -text $a } + if { $a != "" } { + if { [string match "*%*" "$a"] } { + if { [regexp {^([0-9]*)} $a m num] } { + .prog coords bar 0 0 [expr $num * 2] 20 + } + } else { .st configure -text $a } + } } else { if { ! [catch {close $chan}] } { .st configure -text "[.input.id get] Done" + .prog coords bar 0 0 200 20 } .dl configure -state normal -text "Download" + .input.id configure -state normal set dling 0 } } @@ -35,7 +43,9 @@ proc go {} { set cmd "[lindex [lindex $cmds $cmdselected] 0] [.input.id get]" set dling 1 .dl configure -state disabled -text "Downloading" + .input.id configure -state readonly .st configure -text "" + .prog coords bar 0 0 0 20 set out [open "|$cmd 2>@1" "r"] fileevent $out readable [list updateStatus $out] } @@ -102,10 +112,13 @@ foreach b $cmds { button .dl -text "Download" -command go label .st +canvas .prog -width 200 -height 20 -relief sunken -bd 1 +.prog create rectangle 0 0 0 20 -tags bar -fill black + pack .input.lab -side left pack .input.id -pack .cmdfr .input .dl .st +pack .cmdfr .input .dl .prog .st bind . <Return> go bind .input.id <Key> {set manual 1} |