PythonScript Xojo Plugin

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

PythonXojoClassConstructor that takes name and method count

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 event

Sub 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 bit
  • MacOS X Cocoa 64 bit
  • Windows 32 bit
  • Windows 64 bit
  • Linux 32 bit
  • Linux 64 bit
  • Linux ARM