我正在尝试向GUI添加一个停止按钮,该按钮可用于中止gui并在循环时执行背景。考虑一下代码:
function pushFun(button)
disp("Push!")
endfunction
h = figure(1);
set(h,'UserData',1);
button = uicontrol(h, 'Style', 'pushbutton', 'String', 'Stop',..
'Position', [0 0 60 25], 'callback', 'pushFun',..
"callback_type", 2);
哪作得很好。但代码:
function stopgui()
global guistop;
guistop = %t;
endfunction
h = figure(1);
set(h,'UserData',1);
global guistop
guistop = %f;
button = uicontrol(h, 'Style', 'pushbutton', 'String', 'Stop',..
'Position', [0 0 60 25], 'callback', 'stopgui',..
"callback_type", 2);
while ~guistop
// some code here
sleep(100)
end
不响应按钮交互。如果你能帮助我知道什么是错的以及我如何解决它,我将不胜感激。
您必须使用回调类型10(优先(或不可中断)Scilab指令):
button = uicontrol(h, 'Style', 'pushbutton', 'String', 'Stop',..
'Position', [0 0 60 25], 'callback', 'stopgui',..
'callback_type', 10);