summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2012-02-17 18:29:14 +0000
committerNick White <git@njw.me.uk>2012-02-17 18:29:14 +0000
commit4e6e2adeff8b4869de7c4c4fa0a5a3ab241d3a29 (patch)
treeda02dce6fb55145301e841ed3821a9ff323977c0
parentc8fe9f861f16662b99cffcd4b64ec5973f12a7f0 (diff)
Many gui improvements
Feedback on successful download Appropriate list box sizing Better widget placement Show usage of each command Add program dir to path (so can be run from extracted tarball) Be resiliant to errors
-rwxr-xr-xgetxbookgui.tcl33
1 files changed, 24 insertions, 9 deletions
diff --git a/getxbookgui.tcl b/getxbookgui.tcl
index 9183f36..e7cc9e9 100755
--- a/getxbookgui.tcl
+++ b/getxbookgui.tcl
@@ -3,33 +3,48 @@
package require Tk
set bin [list getgbook getabook getbnbook]
+set binopts [list "book id" "isbn 10" "isbn 13"]
+
+set env(PATH) "[file dirname $::argv0]:$env(PATH)"
proc updateStatus {chan} {
if {![eof $chan]} {
set a [gets $chan]
if { $a != "" } { .st configure -text $a }
} else {
- close $chan
+ if { ! [catch {close $chan}] } {
+ .st configure -text "[.top.id get] done"
+ }
.dl configure -state normal -text "download"
.st configure -text ""
}
}
+proc showopts {} {
+ global binopts
+ .top.lab configure -text [lindex $binopts [.bin curselection]]
+}
+
proc go {} {
- if { [.id get] == "" } { return }
- set cmd "[.bin get [.bin curselection]] [.id get]"
+ if { [.top.id get] == "" } { return }
+ set cmd "[.bin get [.bin curselection]] [.top.id get]"
.dl configure -state disabled -text "downloading"
- update
+ .st configure -text ""
set out [open "|$cmd 2>@1" "r"]
fileevent $out readable [list updateStatus $out]
}
-label .lab -text "book id"
-entry .id
-listbox .bin -listvariable bin -exportselection 0
+frame .top
+label .top.lab
+entry .top.id -width 14
+listbox .bin -listvariable bin -exportselection 0 -height [llength $bin]
+bind .bin <<ListboxSelect>> {showopts}
.bin selection set 0
button .dl -text "download" -command go
-label .st -relief sunken -width 20
+label .st
+showopts
-pack .lab .id .bin .dl .st
+pack .top .bin .dl .st
+pack .top.lab -side left
+pack .top.id
bind . <Return> go