Hi,
I have been having trouble with Python threads for a while and decided to
rewrite the threading code in C (using GLib threads) but now I am getting
output to stdout buffered when I call the PyGtk app from the C thread. I was
wondering if there was a way to post the callback event to the applications
main loop somehow so that when the thread returns it processes the callback
just like any other Gtk Event (e.g. mouse click).
I thought of creating a Python thread with a Queue, and posting an object to
the Queue so when the C thread returns the Python thread would see the object
in the Queue and send the object to the Gtk code but that seems overly
complicated. I've pasted the C code that invokes the Python callback.
thanks for any help.
//------------------------------------------------------------------------------
void invoke_event_callback(struct bear_event_t * p)
{
PyObject *arglist;
PyObject *result;
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
arglist = Py_BuildValue("(iss)", p->result, p->src, p->msg);
result = PyEval_CallObject(event_callback, arglist);
/* Release the thread. No Python API allowed beyond this point. */
PyGILState_Release(gstate);
Py_DECREF(arglist);
}
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/