私はtclで初心者でtkで初心者にはうってつけです。 いくつかのテキストをウィンドウに表示したいのですが、いくつかの検索の後に、私にはうってつけの例があります。 私の問題は、ディスプレイがリアルタイムではなく、プログラムが終了したときだけです。 ここに私のプログラムのメインラインがあります。端末のテキストがtcltkウィンドウにリアルタイムで表示されない
Main_program.tcl
#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
exec /usr/local/Cellar/tcl-tk/bin/tclsh "$0" "[email protected]"
set DEBUG 1
source ./GUI_mgt.tcl
source ./utils.tcl
for {set i 0} {$i<500} {incr i} {
after 10
debug_puts $i
}
utils.tcl
proc debug_puts {message} {
if {$::DEBUG} { writeToLog $message }
}
GUI_mgt.tcl
package require Tk
grid [text .log -state disabled -width 80 -height 24 -wrap none]
proc writeToLog {msg} {
set numlines [lindex [split [.log index "end - 1 line"] "."] 0]
.log configure -state normal
if {$numlines==24} {.log delete 1.0 2.0}
if {[.log index "end-1c"]!="1.0"} {.log insert end "\n"}
.log insert end "$msg"
.log configure -state disabled
}
は、質問:何が間違っているか、このコードで逃しましたか? 文章を別のウィンドウに表示するために使用できるパッケージや例が分かりますか?
注:私はMacOSのシエラ10.12.5
Bradさん、ありがとうございました。 別のスレッドで2番目のアイデアを試してみます。私はたくさん好きなアイデアです。 –