summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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