Version 6 of Tailing widget

Updated 2002-12-11 11:54:43

Purpose: provide a mechanism for displaying the end of a file.


  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 ...

See also tail and tailf


Arjen Markus What is not so obvious from the above code, is that there is no easy way to tell whether the process responsible for writing the file that is tailed has finished or not. So, it is not a solution (alas) for monitoring the output of a program that writes to file and then finishes.

DKF 11Dec02 - There's no way to tell that anyway. And in any case, the process writing the file might not be on the same computer either.


People often ask for a way to 'pipe' from an external process into a text widget.


Category GUI