Python3Script Xojo Plugin |

# Python3Script.RegisterXojoModule Method

Registers a Xojo module to expose to python.

shared RegisterXojoModule(
xojoModule as Python3XojoModule,
moduleCreatorFunction as Ptr)

#### Parameters

xojoModule
  The Xojo module to expose to Python.
moduleCreatorFunction
  Address of module creation function. (See notes bellow and the example projects that come with the plugin)

#### Remarks

You should normally call this in your App.Open even right before Python3Script.Init

Note difference from our other PythonScript plugin which is for Python 2.7.x:
For Python 3.4.x then classes exposed from Xojo must be registered before the Init method is called while in 2.7.x we registered them after the Init.
Also since modules are created in different way then you now must include additional parameter which is address of a module creation function in your module
Example:
If not Python3Script.PythonIsFound() then
MsgBox "Correct Python installation was not found on this machine"
Quit()
else
// We register the module to Python
Python3Script.RegisterXojoModule(xojoModule, AddressOf XojoFunctionsForPython.ModuleInit)
// Init the Python engine
Python3Script.Init("TestApp")
end if
Where the ModuleInit function will have code like this here:
Function ModuleInit() As Ptr
// You get this callback when the PythonModule is actually created for this first time.
// This is needed because Python 3.x is very differently wired and doing this internally was not possible.
// DO NOT RETURN ANYTHING HERE EXCEPT JUST WHAT THE MODULECREATEPROC FUNCTION RETURNS
return ModuleHandle.ModuleCreateProc()
End Function

#### See Also

Python3Script Class