Tk Source Code

Artifact [82b06873]
Login

Artifact 82b068738eb6c0ee872a42b2f33578d8d6d767f0a3ae3d720e0cb638818f928c:

Attachment "print_text.tcl" to ticket [4e7a78ea] added by emiliano 2025-05-06 21:51:41.
package require Tk

text .t -yscrollcommand [list .sy set]
ttk::scrollbar .sy -command [list .t yview]
ttk::button .tkprint -command [list after idle [list tk print .t]] \
    -text "Print"

grid .t .sy -sticky news
grid .tkprint - -pady 6
grid columnconfigure . 0 -weight 1
grid rowconfigure . 0 -weight 1

set basedir [file dirname [file normalize [info script]]]
set fd [open [file join $basedir utf8demo.txt]]
chan configure $fd -encoding utf-8
.t insert end [chan read $fd][chan close $fd]