PythonXojoClass Class (console safe)
A class to create new Python classes from Xojo.
In this version there is only support for creating classes with methods, no properties.
PythonObject
PythonXojoClass
class PythonXojoClass
Constructors
Properties
Name (Inherited) (console safe) | Returns the name of the object. |
Methods
RegisterFunction (console safe) | Registers a Xojo function to expose to Python via this class |
Examples
Example from the Application open eventSub Open()
// Init the Python engine
PythonScript.Init("TestApp")
Dim xojoModule as PythonXojoModule
Dim xojoClass as PythonXojoClass
// Create new class type to expose to Python
xojoClass = new PythonXojoClass("MyXojoClass",2)
xojoClass.RegisterFunction("__init__",AddressOf MyXojoClass.Init)
// Add constructor and a function to our new class
xojoClass.RegisterFunction("SomeMethod",AddressOf MyXojoClass.SomeMethod)
xojoClass.RegisterFunction("SomeMethod2",AddressOf MyXojoClass.SomeMethod)
// Create a Python module to host the class
xojoModule = new PythonXojoModule("Xojo",2)
// We add some methods to the module
xojoModule.RegisterFunction("TestHelloFromXojo",AddressOf XojoFunctionsForPython.TestHelloFromXojo)
xojoModule.RegisterFunction("CalculateSomething",AddressOf XojoFunctionsForPython.CalculateSomething)
// Then we add the class to the module
xojoModule.AddClass(xojoClass)
// And finally we register the module to Python
PythonScript.RegisterXojoModule(xojoModule)
End Sub
Supported Platforms:
MacOS X Cocoa 32 bitMacOS X Cocoa 64 bitWindows 32 bitWindows 64 bitLinux 32 bitLinux 64 bitLinux ARM