Jump to content

Heimo

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, I have tried several approaches to pass a Delphi callback function to be used by Python, but the functions are not being called. procedure CallbackFunc(args: Variant); begin Form1.Memo1.Lines.add('111'); // ... end; callback:=PythonEngine1.PyCFunction_NewEx(@CallbackFunc, nil,nil); PythonEngine1.Py_INCREF(callback); //client.subscribe_whole_quote(NewPythonDict,TVarProc(cb)); //codelist := VarPythonCreate(['SZ']); codelist := PythonEngine1.PyList_New(1); PythonEngine1.PyList_SetItem(codelist, 0, PythonEngine1.PyUnicode_FromString('110072.SH')); argsTuple := PythonEngine1.PyTuple_New(2); PythonEngine1.PyTuple_SetItem(argsTuple, 0, codelist); PythonEngine1.PyTuple_SetItem(argsTuple, 1, callback); ss :=GetPythonEngine.EvalPyFunction(ExtractPythonObjectFrom( client.subscribe_whole_quote ), argsTuple); in the code subscribe_whole_quote is a python function have 2 parms, 1st is a list, and 2d is the callback function, when I called the subscribe_whole_quote it returned success, but never call the callback function. int the c# I can only pass the callback like a delegate like: public delegate void onSubDelegate(dynamic datas); public void onWholeSub(dynamic jdatas) { } var onWholeSubdel = new onSubDelegate(onWholeSub); try { List<string> stocklist = new List<string>(){"SH"}; var ret = client.subscribe_whole_quote(stocklist, onWholeSubdel); return ret; } catch (Exception ex) { } it is works fine.
×