0
我是初學者,運行tcl/tk腳本。在我的腳本中,我創建了一個彈出窗口來選擇要打開的文件,然後將此文件路徑提供給源函數。我期待這個腳本逐步運行,但是在我選擇任何文件之前,源代碼函數正在運行。我也嘗試使用vwait函數。不幸的是,它在第一次運行中沒有運行。但在第二次運行中,腳本正在按照願望工作。任何人都可以幫我運行這個腳本嗎?tcl/tk腳本不符合要求
destroy .buttons
toplevel .buttons -width 400 -height 100 -background red -relief ridge -borderwidth 8 -padx 10 -pady 10
wm title .buttons "Select a file containing nodes coordinates"
wm geometry .buttons 350x81
set count 0
proc add_button {title command} {
global count
button .buttons.$count -text $title -command $command
pack .buttons.$count -side top -pady 1 -padx 1 -fill x
incr count
}
set types { {{TCL Scripts} {.tcl}} }
add_button "File name" {set accept_button [tk_getOpenFile -filetypes $types]
\t \t \t \t \t \t \t puts "the path is: $accept_button"
\t \t \t \t \t \t \t
\t \t \t \t \t \t \t destroy .buttons}
add_button "Exit" {destroy .buttons}
#puts above------------------------
#vwait [namespace which -variable accept_button]
#puts below-----------------------
source "$accept_button"
puts "the src is: $accept_button"
您是否收到任何錯誤? – Adam
@Adam不,但腳本沒有運行,因爲我期待它運行。我期待第一個腳本會要求我選擇一個文件,在選擇一個文件後,所選文件將被視爲一個源文件。但是這裏的源代碼和彈出窗口同時運行。我不想要。 –