I think that I would approach it a little differently, with a bit more flexibility. I'd make a function in Python that accepts a string, and then you can call that from your PyRun_SimpleString (or get a reference to the function and call it directly via the API.) Then in the function you can do whatever you like to pass the string over to the GUI thread. (posting an event, using wx.CallAfter, etc.)
Thanks Robin,
I'd like to try doing it that way. Can you give me a few lines of code indicating how you would pass a python function reference into a C extension and call it from the API?
if(PGCommonModule){
if (PyObject_HasAttrString(PGCommonModule, "PrintFromExtension")) {
printFun = PyObject_GetAttrString(PGCommonModule, "PrintFromExtension");
if (PyCallable_Check(printFun)) {
PyObject_CallFunction(printFun, "s", str);
Py_DECREF(printFun);
}
else printf("Error -- 3. PrintFromExtension is not a function\n");
}
else printf("Error -- 2. Module dict does not contain PrintFromExtension attribute.\n");
Py_DECREF(PGCommonModule);
}
else printf("Error -- 1. Could not load module PGCommon");
In PGCommon.py:
def PrintFromExtension(str):
print str
···
-----------------------------------
Now all I have to do is deal with thread/event handling from within PrintFromExtension...
Are there any lurking issues I am not seeing? Thanks again for your help.
-mike
At 11:27 AM 5/26/2006, you wrote:
I think that I would approach it a little differently, with a bit more flexibility. I'd make a function in Python that accepts a string, and then you can call that from your PyRun_SimpleString (or get a reference to the function and call it directly via the API.) Then in the function you can do whatever you like to pass the string over to the GUI thread. (posting an event, using wx.CallAfter, etc.)
Thanks Robin,
I'd like to try doing it that way. Can you give me a few lines of code indicating how you would pass a python function reference into a C extension and call it from the API?
-mike
- mike
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org