Version 3 of a simple file-viewing text widget

Updated 2002-06-21 07:02:43

PT posted this in the comp.lang.tcl newsgroup:

    package require Tk
    text .t -yscrollcommand {.s set}
    scrollbar .s -command {.t yview}
    pack .s -side right -fill y
    pack .t -side left -fill both -expand 1

    set f [open $filename r]
    set data [read $f]
    close $f

    .t delete 0.0 end
    .t insert 0.0 $data

And Marty Backe posted this as a follow-up:

  package require Iwidgets
  iwidgets::scrolledtext .t
  pack .t -fill both -expand true

  .t insert $filename end

To clear the widget between file reads:

  .t clear