我想使用Tcl/Tk制作的GUI在Scilab上显示图像和视频。
Scilab支持Tcl/Tk :- a10b99d9dda4c3d65d29c2a48e58fd88.html。
我已经做了一个tcl脚本,它在从终端运行时显示一个图像。
image create photo img -file <filepath>
pack [label .mylabel]
.mylabel configure -image img但是,当我在scilab中编写以下.sci文件时,它成功地执行,但没有显示图像窗口。
function sampletry()
TCL_EvalFile(<path_to_tcl_file>);
endfunction我知道代码执行成功,因为当我在scilab中再次执行相同的函数时,我会收到一个错误,说明标签.mylabel已经存在于父窗口中。
我是否可以使用这种方法或在Scilab中的任何其他方法在Scilab中显示图像/视频?我使用OpenCV读取图像并通过列表中的Scilab将其返回给Scilab。
发布于 2016-06-17 13:17:50
问题是,您没有为Scilab代码中的事件循环提供服务,没有它,来自操作系统的大量消息实际上就无法通过和处理。假设您希望代码停止并等待查看完成,则只需将Tcl/Tk代码更改为:
image create photo img -file <filepath>
if {![winfo exists .mylabel]} {
pack [label .mylabel]
}
.mylabel configure -image img
wm deiconify .
# Wait for the user to ask for the window to be closed
wm protocol . WM_DELETE_WINDOW {set done 1}
vwait done
# Process the close immediately
wm withdraw .
updatedone变量没有什么特别之处。我们只是在等待在回调中设置它。我添加了一些额外的代码,允许您两次调用它(即,有条件地创建小部件,确保显示.,然后将其隐藏在末尾)。
如果您不想将所有内容都保持在同一个过程中,最简单的方法是将原始脚本作为一个单独的程序运行,有效地执行:
wish <path_to_tcl_file>我不知道从Scilab那里做这件事最简单的方法是什么。
https://stackoverflow.com/questions/37879072
复制相似问题