It is possible to pass a Python callback to C-extensions?

Pierre Rouleau prouleau_nospam_atall_ at impathnetworks.com
Wed Aug 20 11:55:49 EDT 2003


I have a GUI application written in Python (with WxPython) which uses 
some low level classes also written in Python.  These low level Python 
classes are given a pointer to some GUI Python object.  The low level 
Python classes callback some of the methods of the GUI object.  All 
works fine.

Now I want to convert the low level Python classes to C++.  I will be 
using SWIG to create the marshaling so the top level GUI, written in 
Python stays that way.

The problem:  is it possible to continue using call backs?  The C++ code 
would need to call the Python methods back.  Is there an easy way to do 
this?

This is a little different from extending or embedding.  I have a Python 
program that uses Python extensions written in C++.  This C++ code would 
need to pass some information back to the Python code (and currently, 
the all-round Python code uses call backs).

My quick review of the SWIG documentation did not help me find a 
solution to this.

Thanks in advance for any help.

/Pierre





More information about the Python-list mailing list