Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Call backs

Thread Tools

Call backs

Anand K Raydu
Posts: n/a
Hi all,

I have some problems with callback mechanisms,
I have embedded python into my application and want to customize my
application through python.
It is great with respect to calling the my APIS .
Now i have a situation where one of my API calls dialog box , and upon
clicking the dialog box buttons i am invoking python callback.
most of the time callback is failing. unfortunately there is no error
message is also generated.

following is the way i am sending the callback to python & calling it
from c.

main python code:

class myClass:
def __init__(self,value):
self.value = value
def Execute(self):
import myapis
myapis.EventLoop() # this an infinate loop which just gets
all gui events & dispatches like any gui event loop

def myCallBack(self):
import myapis

my C code to get the callback

PyObject *setCallBack(PyObject *self, PyObject *args) {

PyObject *command;
int retvalue =0;

if (!PyArg_ParseTuple(args, "O:setCallBack", &command))
return NULL;

glbCallback = command; // a global python variable
at the time of invocation of the API i have following code

void invokeCallBack()
if( glbCallback == NULL ) return 0 ;

PyObject *arglist;
PyObject *result;

PyGILState_STATE state = PyGILState_Ensure();
arglist = Py_BuildValue("(i)", buttonValue);
result = PyEval_CallObject(glbCallback , arglist);
// The result some times in NULL indicating failure,
// I noticed that if i imort my module in the python callback it is

Can some one please suggest a better way of dealing it.
i want really a robust mechanism for callbacks.
Thanks & Best Regards,

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Call Backs Edward Rutherford C Programming 8 02-17-2012 09:58 PM
passing data to Tkinter call backs Nick Keighley Python 6 06-09-2010 04:17 PM
passing auxiliary data to call-backs and closures (was: pointer) Stefan Ram Java 6 07-17-2009 11:52 AM
extension call backs and the GIL Robin Becker Python 6 09-29-2003 06:36 PM
Post Backs Mark S. ASP .Net 4 08-13-2003 08:47 PM