|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-05-09 08:58:27
"Thierry Lam" <lam_at_[hidden]> writes:
Hi Thierry,
In the future, a better place for Boost.Python questions is
http://www.boost.org/more/mailing_lists.htm#cplussig
> Let's say I have the following in a Python file called progress.py:
>
> pbar = gtk.ProgressBar()
>
>
> def updateBar():
>
> pbar.puls()
>
>
> In C++:
>
>
> // Call the python method updateBar() which is not a member of any
> class in progress.py
>
>
>
> How do I do it?
You need to get ahold of the progress module:
python::object progress((
python::handle<>(
python::borrowed(PyImport_AddModule("progress")))));
Then you can get the updateBar method:
python::object updateBar = progress.attr("updateBar");
Then you can call that:
updateBar();
That's the "slick, modern approach." No need to mess around with
call<...> and friends.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk