Version 6 of a simple file-viewing text widget

Updated 2005-11-21 15:24:46

PT posted this application of the text widget 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

Category GUI - Category File