Welcome, guest | Sign In | My Account | Store | Cart

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.

Tcl, 25 lines
 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 ...
Created by Jeff Hobbs on Thu, 21 Jun 2001 (MIT)
Tcl recipes (162)
Jeff Hobbs's recipes (16)

Required Modules

  • (none specified)

Other Information and Tasks