[email protected] wrote:
>> [email protected] wrote:
>>> I've been using FLTK to wrapper very complex engineering calculations..
>> See Fl::check():
>> http://fltk.org/documentation.php/doc-1.1/Fl.html#Fl.check
>>
>> Call Fl::check(); within your calculation so that FLTK
>> can have some CPU to keep the interface alive.
>>
> I tried that, it didn't work.
Right; sorry -- think I followed up with a better example.
Since your calculation is in a separate program being read
through popen(), your FLTK app is likely blocking during
the fread()/fgets() operations.
So unless you can make those operations non-blocking,
you'll need to use a thread to manage the popen()/reading/pclose()
to ensure your app and FLTK doesn't block.
This example avoids threads, but only works under unix, and
shows how to use popen + fltk:
http://seriss.com/people/erco/fltk/#add_fd
There's also this other, more complex example:
http://www.seriss.com/people/erco/fltk/#Fltk-tty
..which shows how to use fork()/exec() in place of popen()
with Fl::add_fd() to keep FLTK alive while watching for
output from not one, but *three* different external programs
all running simultaneously, each updating to separate FLTK
text widgets.
But if you're using Windows, don't use the above two approaches.
The best way to go is create a thread to handle the popen()+read+close,
and have the main thread to watch for data as it comes in using
either the Fl::check() approach to poll for new data, or create
an Fl::add_timeout() that watches for data 4 or 5 times per second.
I don't have an example for that ATM, but if I find some time,
I can maybe supply one.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk