Tcl 如何为2个变量设置vwait

Tcl 如何为2个变量设置vwait,tcl,tk,Tcl,Tk,我的目标是执行以下(简化)代码: 在myprocessor.tcl中 proc Process {} { set inp_file_name [[tk_getOpenFile -initialdir "./"] read_lines set lines [Proceed $inp_lines] } 在处理变量inp_file_name和行时,我想在小部件中显示这些更改。怎么做?这是上面示例的工作原型。您遇到的关键问题是标签没有将其-textvariable属性设置为in

我的目标是执行以下(简化)代码:

在myprocessor.tcl中

proc Process {} {
    set inp_file_name [[tk_getOpenFile -initialdir "./"]
    read_lines
    set lines [Proceed $inp_lines]
}

在处理变量inp_file_name和行时,我想在小部件中显示这些更改。怎么做?

这是上面示例的工作原型。您遇到的关键问题是标签没有将其
-textvariable
属性设置为
inp\u file\u name
全局变量。文本行插入MyProcessor::Process过程中的文本小部件中

namespace eval MyProcessor {

    proc Process {} {
        set file_name [tk_getOpenFile -initialdir "./"]
        set h [open $file_name r]
        set lines [read $h]
        .inpTxt insert end $lines
        close $h
        return $file_name
    }
}

proc Open_file {} {
    global inp_file_name
    set inp_file_name [MyProcessor::Process]
}
# Upper frame
frame .top
grid .top
# Input file name
set inp_file_name "Input file name (press button -->)"

# Set the textvariable attribute to the global inp_file_name variable.
label .top.lbInpFileName -textvariable inp_file_name
button .top.btInpFile -text "..." -command Open_file
grid .top.lbInpFileName .top.btInpFile
# Two edits
text .inpTxt
text .outTxt
grid .inpTxt
grid .outTxt

我试图将GUI与处理分开(将处理放在文件myprocessor.tcl中的模块中),所以我搜索查看模块中变量状态的方法。
namespace eval MyProcessor {

    proc Process {} {
        set file_name [tk_getOpenFile -initialdir "./"]
        set h [open $file_name r]
        set lines [read $h]
        .inpTxt insert end $lines
        close $h
        return $file_name
    }
}

proc Open_file {} {
    global inp_file_name
    set inp_file_name [MyProcessor::Process]
}
# Upper frame
frame .top
grid .top
# Input file name
set inp_file_name "Input file name (press button -->)"

# Set the textvariable attribute to the global inp_file_name variable.
label .top.lbInpFileName -textvariable inp_file_name
button .top.btInpFile -text "..." -command Open_file
grid .top.lbInpFileName .top.btInpFile
# Two edits
text .inpTxt
text .outTxt
grid .inpTxt
grid .outTxt