Comp.lang.tcl questioners frequently demand some sort of
gadget to monitor an ongoing process and display the result in a
text. The following widget is the simplest answer I know that meets
the common intent of these requests.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 | proc setup filename {
text .t -width 60 -height 10 -yscrollcommand ".scroll set"
scrollbar .scroll -command ".t yview"
pack .scroll -side right -fill y
pack .t -side left
set ::fp [open $filename]
seek $::fp 0 end
}
proc read_more {} {
set new [read $::fp]
if [string length $new] {
.t insert end $new
.t see end
}
after 1000 read_more
}
setup logfile
read_more
# Notice this is portable code.
# An industrial-strength version would probably exploit
# namespaces ...
|
Sign in to comment