From: Matt Fig on 8 Jan 2010 15:55 The drawnow command flushes the graphics event queue. The pause command will also trigger a flushing of the queue, so you don't need both in the loop. To see what happens if you don't flush the event queue, take these two lines out and run the code. function [] = stoploopgui() S.fh = figure('menubar','none',... 'units','pix',... 'pos',[400 400 100 50]); S.pb = uicontrol('string','stop',... 'callback',{@pb_call},... 'units','pixels',... 'position',[10 10 80 30]); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% S.pb(2) = uicontrol('visible','off'); n = 1; drawnow; % Draw the GUI before we enter the loop! for ii = 1:inf if ~ishandle(S.pb(2)) break; end % drawnow; n = n + 1; end disp(n) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [] = pb_call(varargin) % Callback for pushbutton delete(S.pb(2)) end end
First
|
Prev
|
Pages: 1 2 Prev: read input variables from a file Next: C# To call a Compiled DLL:Error |