shineworld 85 Posted 4 hours ago I'm using TreeView and I'm trying to disable the node collapsing with event OnCollapsing(Sender, Node, AllowCollapse). The Python method is called when a TreeView node is clicked for collapse: def TreeViewCollapsing(self, Sender, Node, AllowCollapse): AllowCollapse = False In the event I've set AllowCollapse to False, but in engine code the AllowCollapse := PyObject_IsTrue(LVarParam.Value) = 1; returns True: procedure TTVCollapsingEventHandler.DoEvent(Sender: TObject; Node: TTreeNode; var AllowCollapse: Boolean); var LPyObject, LPyNode, LPyTuple, LPyResult, LPyAllowCollapse: PPyObject; LVarParam: TPyDelphiVarParameter; begin Assert(Assigned(PyDelphiWrapper)); if Assigned(Callable) and PythonOK() then with GetPythonEngine() do begin LPyObject := PyDelphiWrapper.Wrap(Sender); LPyNode := PyDelphiWrapper.Wrap(Node); LPyAllowCollapse := CreateVarParam(PyDelphiWrapper, AllowCollapse); LVarParam := PythonToDelphi(LPyAllowCollapse) as TPyDelphiVarParameter; LPyTuple := PyTuple_New(3); PyTuple_SetItem(LPyTuple, 0, LPyObject); PyTuple_SetItem(LPyTuple, 1, LPyNode); PyTuple_SetItem(LPyTuple, 2, LPyAllowCollapse); try LPyResult := PyObject_CallObject(Callable, LPyTuple); if Assigned(LPyResult) then begin Py_DECREF(LPyResult); AllowCollapse := PyObject_IsTrue(LVarParam.Value) = 1; end; finally Py_DECREF(LPyTuple); end; CheckError(); end; end; Share this post Link to post
shineworld 85 Posted 4 hours ago An user wrote me "AllowCollapse.Value = False" instead of "AllowCollapse = False".... Work! Thank you Share this post Link to post