[Image-SIG] TK image interface with compute intensive code

Klamer Schutte Schutte@fel.tno.nl
Wed, 10 Jul 2002 01:15:06 +0200


I am looking for a way to integrate my pyhton code capable of
(interactively) displaying an image (through PIL) with some
computation intensive C code.

What I have seen this far in the following code:

  PyRun_SimpleString("frame=Toplevel()");
  sprintf(comm, "viewer.viewer(frame, '%s',im)", argv[1]);
  PyRun_SimpleString(comm);
  PyRun_SimpleString("root.update()");
  sleep(10);
  PyRun_SimpleString("frame=Toplevel()");
  sprintf(comm, "viewer.viewer(frame, '%s',im)", argv[1]);
  PyRun_SimpleString(comm);
  PyRun_SimpleString("root.update()");

here I try to visualize something from my C++ code. im is the
Python name for my image, and viewer.viewer() the python viewer
with callbacks on mouse clicks.
The sleep(10) is a placeholder for what might happen in
my own code. 10 seconds of not being able to handle the image
window is not what I want.

I tried to have a Tkinter root.mainloop() set up before as 
separate thread:

  PyRun_SimpleString("thread.start_new_thread(root.mainloop,())");

However, this also didn't give me the responsive image viewer I
am looking for.

Anybody a hint how to get the C++ code running independent of the
python interface?

Klamer