|OOo Extensions project
Please view the wiki usage guidelines
|Extensions on the main site|
Python and OpenOffice.org
OpenOffice.org ships with the python scripting language, version 2.6.1 since 3.1. Older OpenOffice.org ships with Python version 2.3.4. This Python distribution comes with the Uno module, which connects the UNO API to the python scripting language. To run this version of Python on Linux, you can go directly to the OpenOffice.org PATH. And as one would expect with any distribution of Python, OOo-Python can be run from the command line as well.
Where is the IDE ?
OpenOffice.org's IDE doesn't support Python, so development has to be done from another editor that does. Any volunteer for a binding is welcomed.
Tips & Tricks
Here is some useful information about using python in OOo.
If you launch a python script, any error will silently break the execution, making your extension hard to debug. To change this behaviour, one can change the LogLevel .
Have a look in /path/to/ooo/program/pythonscript.py and replace LogLevel.use = LogLevel.NONE with LogLevel.use = LogLevel.DEBUG .
There are also currently-undocumented environment variables that tell the pyUno bridge to log every call. Set the environment variable export PYUNO_LOGLEVEL=ARGS . The output may be a little hard to read, but helpful nonetheless.
Note that his applies only to Linux. For Windows, you need some more switches, and the output gets written to files (there is no stdout on windows :-( ).
There are still some error messages that won't appear in these logs; this will improve in the near future (cws pyunofixes4). Once the cws is integrated, I will document these switches on the official pyuno site.
Thanks to Joerg Budischewski .
Python specific information for Extension creation
To create extensions for python, it is important that you have enough familiarity with the UNO components, as well as with packaging your code for easy distribution through the OpenOffice.org package manager. Please check the tutorials to learn how to component-ize your code, and how to deploy remote scripting through a service implementation.
To learn to run Python on Windows, visit this link for more detailed information.
- Using Python on Windows - New to Python? Learn how to use python on Windows
- Using Python on Linux - A must read for an overview on Python and OOo relations
- pyUNO bridge - Official page of the PyUNO bridge at the UDK site
- Python as a macro language in OpenOffice.org 2.x - How to use the Python scripting framework
- PyUNO Manual Lukasz created a pyUNO manual. new
- Starting/Stopping and connecting using Python From Linux Journal
- Introduction on testing pyUNO programs with doctests
- Create a dialog box in PyUNO.
- Connect to openoffice.org from PyUNO
- PyUNO samples currently shipping with OpenOffice.org and the explanation.
- Enhanced Capitalized.py script by The gray Cardinal at OOoforum.
- Danny's Python Modules - Collection guide from DannyB's modules.
- PrinttoWriter.py - This makes it easy and convenient to print a bunch of text into a Writer document.
- Developing Calc Functions in Python - Learn how Python can be used to script your spreadsheets
- Generating a Spreadsheet through Python - Automatically generate new spreadsheets
- Python container components
- PyUNOServer - The PyUNOServer is a script that works as an XML server for OpenOffice.org Calc
- calcParser - calcParser is a small parser using the native SAX utilities within the OpenOffice.org python
- OoConfig - OoConfig is a Python extension that seeks to provide a configuration editing facility similar to Mozilla's about:config
- OOoRISExport.py - Exports the bibliographic database in RIS format. Also RISImport.py
- Zotero Plugin - The Zotero plugin provides citation and bibliographic table insertion and editing functions for Writer documents.
- UNO component packaging - How to create UNO components as well as the basics of script componentizing
- Python component to parse XML - Python is great to parse XML, PyUNO is also excellent when working with XML
- Example of Service in Python - Learn how to run Python as a service, this is useful for remote scripting.
- Modify spreadsheet - Example of storing and retrieving a custom attribute on a spreadsheet cell.
- A simple daemon in Python - Learn how to run Python as a daemon
- Loook.py - a simple Python tool that searches for text strings in OpenOffice.org.
- odt2txt.py - convert ODF to plain text using python (and convert the txt to html).