[C++-sig] Boost::Signals - Python functions as slots
Benny Kramek
benny at kramekweb.com
Fri Mar 26 13:26:33 CET 2004
I'm using Boost::Signals in C++. I want to be able to attach python
functions as slots to the C++ signals. Here is a very simple test that
doesn't work. Everything compiles OK, but I get a Python error.
### C++ class
class Button
{
public:
void doOnClick(const boost::signal<void ()>::slot_type& slot);
private:
boost::signal<void ()> onClick;
};
void Button::doOnClick(const boost::signal<void ()>::slot_type& slot)
{
onClick.connect(slot);
}
### Boost::Python Module
class_<Button>("Button")
.def("doOnClick", &Button::doOnClick)
;
### Python test
def f():
print 'f'
button = Button()
button.doOnClick(f)
### Python error
button.doOnClick(f)
Boost.Python.ArgumentError: Python argument types in
Button.doOnClick(Button, function)
did not match C++ signature:
doOnClick(Button {lvalue}, N5boost4slotINS_8functionIFvvESaIvEEEEE)
The demangled name
N5boost4slotINS_8functionIFvvESaIvEEEEE
is
boost::slot<boost::function<void ()(), std::allocator<void> > >
I'm using gcc 3.2.3 and boost 1.31.0
Thanks for any help,
Benny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040326/5b0f3671/attachment.htm>
More information about the Cplusplus-sig
mailing list