내 문제를 재현하는 코드는 아래와 같습니다. 나는Tcl/Tk - eval을 사용하여 명령을 실행 한 후 프롬프트를 표시하는 방법은 무엇입니까?
% wish
% source test.tcl
%
입력 test.tcl
#-------------------------------------------------------------------
# test.tcl
#-------------------------------------------------------------------
namespace eval Gui {
}
proc Gui::test {} {
toplevel .test
wm title .test "Test"
wm resizable .test 0 0 ;# not resizable
# create a frame to hold the check widgets
set f [frame .test.boolean -borderwidth 10]
pack $f -side top
# OK and Cancel buttons
button .test.ok -text "OK" -command [list Gui::Ok .test ]
button .test.cancel -text "Cancel" -command [list Gui::cancel .test ]
pack .test.cancel .test.ok -side right
bind .test <Return> {Gui::Ok .test ; break}
bind .test <Escape> {Gui::cancel .test ; break}
}
proc Gui::Ok { arg } {
set x [list puts "hello world!"]
eval $x
destroy $arg
}
proc Gui::cancel { arg } {
destroy $arg
}
#-------------------------------------------------------------------
# Gui main window
#-------------------------------------------------------------------
proc Gui::initialize { } {
# build the frame which contains menu options
frame .mbar -relief raised -bd 2
frame .mdummy -width 200 -height 240
pack .mbar .mdummy -side top -fill x
# menu options
menubutton .mbar.command -text Command -underline 0 -menu .mbar.command.menu
pack .mbar.command -side left
# menu under command options
menu .mbar.command.menu -tearoff 0
.mbar.command.menu add command -label "Test..." -command [list Gui::test]
}
#-------------------------------------------------------------------
# main code
#-------------------------------------------------------------------
Gui::initialize
로 파일을 이름을 지정하고 나는 나에게
% hello world!
가 인쇄 후 난 다시 프롬프트 %
을하지 않습니다를 제공하는 Command -> Test ... -> OK
을 클릭 hello world!
. 비록 내가 그 공간에서 tcl 명령을 실행할 수는 있지만. 예 :
% hello world!
puts "hi"
hi
%
프롬프트를 반환합니다.
내 질문 : TCL/TK는 hello world!
"Enter"키만 누르면됩니다. – GrAnd