Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface while循环阻止从gui读取回调_User Interface_While Loop_Callback_Scilab - Fatal编程技术网

User interface while循环阻止从gui读取回调

User interface while循环阻止从gui读取回调,user-interface,while-loop,callback,scilab,User Interface,While Loop,Callback,Scilab,我正在尝试向GUI添加一个停止按钮,该按钮可用于中止GUI并执行后台while循环。考虑代码: 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',

我正在尝试向GUI添加一个停止按钮,该按钮可用于中止GUI并执行后台while循环。考虑代码:

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
这很好用。但守则:

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);