How To Configure Pycharm To Develop Libreoffice Python Macros?
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:
- Download PyCharm and create a new project.
- It asks which interpreter to use. Click on the gear icon and specify
Add Local
. Browse toC:\Program Files (x86)\LibreOffice 5\program\python.exe
. - 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?"