prabhuusic
Programmer
Hi All,
I have created a text widget in tcl/tk with a vertical scrollbar. I am trying to write a command output from tcl to tk text widget. I would like to scroll the read text before the command get finished.
(i.e asynchronously reading from a pipe). But with the following code the form is getting blocked during the time of writing data to text widget.
Here is the piece of code that I am trying to solve ...
########################################################
set log [text .t -yscrollcommand {.t.yscroll set}]
scrollbar .t.yscroll -command {.t yview} -orient v
pack .t.yscroll -side right -expand yes -fill y -anchor e
pack .t -side left -expand yes -fill both
bind . <Escape> {exit}
wm geometry . 700x400
proc isReadable { f } {
global log
set status [catch { gets $f line } result]
if { $status != 0 } {
puts "error reading $f: $result"
set :ONE 2
} elseif { $result >= 0 } {
#puts "got: $line"
$log insert end $line\n
$log see end
update idle
} elseif { [eof $f] } {
puts "end of file"
set :ONE 1
} elseif { [fblocked $f] } {
# Read blocked. Just return
} else {
# Something else
puts "can't happen"
set :ONE 3
}
}
set fid [open "|ls -lR /"]
fconfigure $fid -blocking false
fileevent $fid readable [list isReadable $fid]
vwait :ONE
close $fid
########################################################
Can someone guide to resolve the above issue ...!
Thanks in Advance ...
Prabhakar. K
ICL Engineer
SoCtronics Tech. Pvt. Ltd.
Hyderabad-INDIA
I have created a text widget in tcl/tk with a vertical scrollbar. I am trying to write a command output from tcl to tk text widget. I would like to scroll the read text before the command get finished.
(i.e asynchronously reading from a pipe). But with the following code the form is getting blocked during the time of writing data to text widget.
Here is the piece of code that I am trying to solve ...
########################################################
set log [text .t -yscrollcommand {.t.yscroll set}]
scrollbar .t.yscroll -command {.t yview} -orient v
pack .t.yscroll -side right -expand yes -fill y -anchor e
pack .t -side left -expand yes -fill both
bind . <Escape> {exit}
wm geometry . 700x400
proc isReadable { f } {
global log
set status [catch { gets $f line } result]
if { $status != 0 } {
puts "error reading $f: $result"
set :ONE 2
} elseif { $result >= 0 } {
#puts "got: $line"
$log insert end $line\n
$log see end
update idle
} elseif { [eof $f] } {
puts "end of file"
set :ONE 1
} elseif { [fblocked $f] } {
# Read blocked. Just return
} else {
# Something else
puts "can't happen"
set :ONE 3
}
}
set fid [open "|ls -lR /"]
fconfigure $fid -blocking false
fileevent $fid readable [list isReadable $fid]
vwait :ONE
close $fid
########################################################
Can someone guide to resolve the above issue ...!
Thanks in Advance ...
Prabhakar. K
ICL Engineer
SoCtronics Tech. Pvt. Ltd.
Hyderabad-INDIA