Python3Script Xojo Plugin |
|
Python3XojoModule.RegisterFunction Method
Registers a Xojo function to expose to Python via this module

RegisterFunction(
name
as String,
fuction
as Ptr)
Parameters
- name
- Name of the function as Python should see it. This name does not have to be same as the name of the Xojo function.
- fuction
- Address of the Xojo function that should by called from Python.
Note
The parameters and return value must always be as follows:
SomeFunctionName(pySelf as Ptr, pyArgs as Ptr) as Ptr
Remarks
Example function in Xojo with correct function parameters and result value:
Function CalculateSomething(pySelf as Ptr, pyArgs as Ptr) As Ptr
Dim params as Python3Parameters = new Python3Parameters(pyArgs)
if params.Count = 2 then
if params.IsInteger(0) and params.IsInteger(1) then
return Python3Result(new Python3Result(params.IntegerValue(0) + params.IntegerValue(1))).GetPtr()
end if
end if
Python3Script.SetError(Python3ErrorTypes.TypeError,"CalculateSomething must have exactly 2 integer parameters")
End Function
See Also
Python3XojoModule Class