Skip to content Skip to sidebar Skip to footer

How To Configure Pycharm To Develop Libreoffice Python Macros?

I've installed Python 3.5.1 as default in Win7(x64) for all my projects in Python. I use PyCharm 5.0.5 community edition for develop Python scripts and its default settings has 'De

Solution 1:

From the PyCharm documentation, it sounds like you could use a virtual environment to target LibreOffice (likely Python 3) and OpenOffice (likely Python 2) in two different projects. Otherwise it looks like a local interpreter is enough.

To test PyCharm, I did the following:

  1. Download PyCharm and create a new project.
  2. It asks which interpreter to use. Click on the gear icon and specify Add Local. Browse to C:\Program Files (x86)\LibreOffice 5\program\python.exe.
  3. Create a new python file.

Then add this code:

import uno
from com.sun.star.awt import Point

p = Point(2,3)
print(p.X)
points = uno.Any("[]com.sun.star.awt.Point", (p,))
print(repr(points))

It underlined the com import statement, although it's not actually an error. PyCharm did recognize the other statements such as uno.Any.

To run, go to Run -> Run. It ran successfully and printed results as expected.

Instead of an IDE, I typically just use a text editor. From what I have seen, a lot of the IDE tools (syntax highlighting, auto completion, debugging) do not work very well with UNO anyway. It is better with Java, but that is a different topic.

By the way, are there any method to insert macros in the document, to share it with the document [...]?

To embed Python code into a document, unzip the .odt file and follow the instructions here.

Post a Comment for "How To Configure Pycharm To Develop Libreoffice Python Macros?"