Page 1 of 1

PyUNO: Python on the UNO API

Posted: Sat May 05, 2007 12:05 am
by Jza
Image
So as I mention on the show I talked about python binding to OpenOffice.org. I mantain a wiki page with a bunch of links to jump into Python and the UNO API of OOo.

I have examples divided into beginners, medium and hacker. You can check out the page here,

OpenOffice.org includes already some macros on Python on the default installation. You can find it here:

Code: Select all

/usr/lib/ooo-2.2/program/pythonloader.py
....depending on your distro...
Also the examples would be here:

Code: Select all

/usr/lib/ooo-2.2/share/Scripts/python/
You will see a list of samples like HelloWorld.py .

Code: Select all

# HelloWorld python script for the scripting framework

def HelloWorldPython( ):
    """Prints the string 'Hello World(in Python)' into the current document"""
#get the doc from the scripting context which is made available to all scripts
    model = XSCRIPTCONTEXT.getDocument()
#get the XText interface
    text = model.Text
#create an XTextRange at the end of the document
    tRange = text.End
#and set the string
    tRange.String = "Hello World (in Python)"
    return None