如何在scilab中使用按钮停止操作

时间:2019-06-08 17:53:16

标签: scilab

我希望可以通过按下另一个按钮来停止某个按钮启动的功能。更准确地说,我想通过更改参数来停止while循环:

stop=%F
while ... & stop<>%T
    ...
end

我试图编写一个回调函数来更改变量以停止while:

function callback(handles)
    stop=%T
end

但该操作不会在上一个操作结束之前触发。

我想某些线程可能与某些事情有关,但是我在scilab中没有这方面的知识。

1 个答案:

答案 0 :(得分:0)

您有两种解决方案。第一个具有优先级表达式回调的

b = uicontrol("style","pushbutton","callback","stop=%t","callback_type",10);
stop = %f;
while ~stop
    sleep(1)
end

具有优先函数回调的第二个:

function fun()
    stop = %t;
    stop = resume(stop);
end

b = uicontrol("style","pushbutton","callback","fun","callback_type",12);
stop = %f;
while ~stop
    sleep(1)
end

在第二种情况下,您必须使用resume返回主工作空间中的局部变量stop。必须优先设置回调才能中断等待循环。