Re: Question: Making a Gtk+ application interacts with octave (ups)



First thing is, how exactly are you starting the GTK app from octave? 
Octave has a system() function, as well as fork()/exec(), just like C.
 Probably you will want to use the latter, since it gives you
information about process ID's.

2005/7/18, amartinez atc ugr es <amartinez atc ugr es>:

  - Not to die when the image is shown.

Normally, your GTK app would have no reason to die just because the
image is shown... if it has a mainloop, it should keep running through
the loop until the user kills it somehow.

  - Be able to represent another image in the same created window.

This is tough.  You will need to have a way to communicate the data in
the new image to the GTK app while it's running.  If you actually
patched octave to use GTK, then this isn't going to be a problem. 
However I'm guessing you called an external GTK program from within
Octave, so you will need to use some form of IPC like sockets or
pipes.

  - Die with another command from Octave ...

Since Octave has a fork() function that works just like C's, use it
(and exec()) to start the GTK app and get the PID of the new process. 
Something like this:

[pid, msg] = fork();
if (pid == 0)
   [err, msg] = exec('gtk_imshow_app');
   fprintf(2, 'Cant execute the thingy: %s\n', msg);
   return;
end
printf('PID of GTK thingy is %d\n', pid);


Note:
  - One time the user has called gtk_imshow from Octave's command shell,
the control returns to the Octave's prompt (how can I do this?)

This happens automatically if you are using fork() and exec() as I
have described (there might be more to it; you may need to tell Octave
to ignore SIGCHLD or something).  If you are using system(), just
stick an & at the end of the command line to be executed (just like a
shell).

-->  This way for implementing imshow is too slow for me because I'd like
to carry out real-time video processing. A new image window every time
imshow is called is not a good idea for video processing ...

If you really want speed, the best thing will probably be to patch
Octave to incorporate GTK.  I'm sure the Octave people will be pleased
if you do this; I know I would.

-Alem



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]