[scilab-Users] Main thread yield to graphics events

Flemming Nyboe flemming at nyboe.net
Tue Aug 18 22:46:07 CEST 2009


Hi again,

I have discovered one thing regarding my question below, which I thought I
would share here in case it could be useful to someone else.

The problem (see below) only occurs when a script has been started from
scipad, by the 'Execute'->'Load into Scilab' menu command.
However when the script is started from the Console, either by 'File' ->
'Execute', or from the command line using exec(), the graphics events will
in fact fire.

Happy coding,
Flemming, Denmark

-----Original Message-----
From: Flemming Nyboe [mailto:flemming at nyboe.net] 
Sent: 12 August 2009 08:36
To: users at lists.scilab.org
Subject: [scilab-Users] Main thread yield to graphics events

Hello,

I have an infinite while loop processing graphics in a figure. I'm trying to
break the loop when the user closes the figure, but it seems that the
execution thread never yields to the graphics events.

The below code does not end (print "done") when I close the figure.

1) is there a way to force a "do-events" where graphics events are given
time to fire?
2) alternatively, is there a way to detect if a keyboard key has been
pressed without waiting if not.

Regards
Flemming, Denmark

----------------
// detecting closed figure

function my_eventhandler(win,x,y,ibut)
  global run
  if ibut==-1000 then 
    run=0;
  end
endfunction

global run
run=1;

plot2d()
seteventhandler('my_eventhandler')
fh=gcf();

while run,
 if (length(winsid())==0) then
    run=0;
 end
 if ~is_handle_valid(fh) then
   run=0;
 end

 drawnow();
 sleep(2);

end

seteventhandler('') //suppress the event handler

printf('done\n');
----------------




No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.392 / Virus Database: 270.13.50/2296 - Release Date: 08/11/09
06:10:00






More information about the users mailing list