Since Python Win32 lib does not implement DDE Advise Loop and i need it for
a project, i guessed that Boost Python would be a way to integrate the ddeml
lib with my python code. I guessed i could just call call_method inside the
DDE Callback function, but when i do that python crashes. I can't(or couldnt
find how to) add the DDE Callback function to the Python Module and i tried
through a 2 stages call(DdeCallback calls a Python Module function that
call_method) without success. Everything else works great... I can connect
to the DDE Server, the advise loop works, my setPyCallback/getPyCallback
works... I just can't get any python to work on the C++ DDECallback
function.
Here is part of the code
--
PyObject* myPythonCallback;
void CallPy(TCHAR SomeValue){
boost::python::call(myPythonCallback,SomeValue);
}
HDDEDATA CALLBACK DdeCallback(UINT wType,UINT uFmt,HCONV hconv,HSZ hsz1,HSZ
hsz2,HDDEDATA hData,DWORD dwData1,DWORD dwData2){
..
switch (wType) {
case XTYP_ADVDATA:
.. bunch of code ..
CallPy(mybuffer);
return((HDDEDATA)DDE_FACK);
}
int ddeConnect();
void ddeAdvise(TCHAR* topic);
void setCallback(PyObject* p){
boost::python::call(p,"3");// test calling function and WORKS
myPythonCallback = p;
}
BOOST_PYTHON_MODULE(extending)
{
using namespace boost::python;
def("ddeConnect", ddeConnect);
def("ddeAdvise", ddeAdvise);
def("ddeSetCallback", setCallback);
def("CallPy", CallPy);
}
-
Python
import extending
import wx
import justAFrame
def mCB (valor):
print "mCB",str(valor)
return float(str(valor))
class MyFrame(justAFrame.MyFrame):
def initAfter (self):
justAFrame.MyFrame.initAfter(self)
extending.ddeConnect()
extending.ddeSetCallback(mCB)
extending.CallPy("1") #WORKS
extending.ddeAdvise("0012PETR4;1")
app = wx.PySimpleApp()
frame=MyFrame(None,title="DDE Test")
app.MainLoop()
--
How can i make this DdeCallback to interact with a python function defined
by the user ? Is there a better way to do this ? I'm open to suggestions.
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig