last day (14 days later) » 

1:58 PM
Hello Slander! This is a chat room to discuss stackoverflow.com/questions/44980696/…. Specifically, how to get python to work with LibreOffice.
The tutorial you linked to is a good one. How far did you get in it?
 
2:15 PM
The main PyUNO page is at wiki.openoffice.org/wiki/Python
 
2:29 PM
The locations where python scripts may be placed are described at wiki.openoffice.org/wiki/Python_as_a_macro_language
 
2:45 PM
Are you on linux or windows?
 
3:06 PM
Hello, sorry I cannot connect earlier...
I'm under linux. I will take a look at the links you provided here
Ok, I understood the fact I have to embed the python script file in the LO document. But when I use the provided script (include_macro.py), after I've modified its content to match my "script to add to document", I have an warning telling me:
Include_Macro_In_Document.py:23: UserWarning: Duplicate name: 'META-INF/manifest.xml'
doc.writestr('META-INF/manifest.xml', ''.join(manifest))
I saw a similar message in the comments below the tutorial, but it is not excatly the same as I don't have any script added to my macros in LO... Do you have an Idea?
 
First, do it the easier way, which is to put it in the user directory.
Do you see instructions for how to do that?
 
Let me check quick...
do you mean the shared directory?
 
3:21 PM
No, the user directory, which is the first approach described at wiki.openoffice.org/wiki/Python_as_a_macro_language
 
Oh! ok missed that part sorry... Ok got it!
 
On my system it's at ~/.config/libreoffice/4/user/Scripts/python
 
mine is in "~/.config/libreoffice/4/user/" But I dont have "Script" directory yet... Should I create it and its sub one too?
 
Yes.
 
ok done
 
3:26 PM
Then create a file for example "keep_changing.py", and put in the code I posted in the question. The last line in the file should be the g_exportedScripts line.
 
ok done
Btw, the file should start by:
import time
from threading import Thread
import uno
 
To run it, in LibreOffice go to Tools -> Macros -> Run Macros, and expand My Macros to find keep_changing.py.
 
then the 2 "def"s?
 
Yes, that is correct.
 
ok checking in LO
there is nothing more
Btw, i'm french
 
3:32 PM
Go to where keep_changing.py is located. What does "pwd" produce?
 
does the .py file have to be executable?
pwd produces "/home/slander/.config/libreoffice/4/user/Scripts/python"
 
There may be some permission requirements; I'm not sure.
Either on "Scripts" and "python" or on the python script itself.
Try setting them to executable and see if it helps.
 
chmod +x on the .py file does nothing
I'm the owner of the folders in RW
still nothing in the macro editor in LO
 
How about chmod a+rwx
And on the directories.
 
still nothing in LO
:(
 
3:39 PM
:(
It should work.
 
well, folowing your instructions and the tutorials, yes :D
maybe my python script is not correct, so not loaded by LO?
 
Ok, I think I see the problem.
There should also be "Capitalise" in the list, but it is not.
 
which list?
my screenshot?
 
In the shared directory list in your screenshot.
So that suggests that python support did not get installed correctly on your system.
 
oh! ok...
 
3:43 PM
What brand of linux?
 
Xubuntu
16.04
 
I did not install any python package since normal installation... So you are probably right
 
The main point of the link: sudo apt-get install libreoffice-script-provider-python
 
installing...
done
 
3:47 PM
To test, enter in a command prompt "python3" and then "import uno"
If no errors, then you now have pyuno installed.
 
well, I did otherwise lol I checked in LO and I now have access to "Python..." entry below "LibreOffice Basic..." in the Tools > Macros menu
 
:)
 
:)
now I should be able to add the script in my document with the python script "Include_Macro_In_Document.py" right?
 
Were you able to get "keep_changing_cell" to run successfully?
 
did not try yet... Was waiting for your reply. Ok doing it right now
hum... Can I call it from a basic sub?
 
3:54 PM
What happened when you tried to run it?
It looks like you are using the version of my code that expects "=NOW()" in a cell somewhere.
 
Nope I modified the code for your edit and it works perfectly!
now, I already have a macro (in basic) which is triggered when the document opens... How to add your solution to my basic code?
 
What does the other macro do?
 
complex job... It is a comptability software with an User Interface, so the "Open document" event is used to shape the interface correctly...
So by your answer I guess I cannot simply call the python method from the basic code...
maybe the inside/out is possible? calling basic code from python?
 
You can do both.
 
oh?!
 
4:01 PM
I'm trying to decide which way would be easier.
 
ok :p
you are the boss on that man!
 
There's this thing called com.sun.star.script.provider.MasterScriptProviderFactory
Here's a link that looks pretty good: stackoverflow.com/questions/7591656/…
 
ok, I thank you very much for your help... I will have to leave in 10 minutes aprox, so I will learn your link and try to figure it out... The missing part in here was the python not installed correctly... Thanks for that as you saw it with expert eyes :D
Your script is working as I expected... Did not try but I other events will trigger while the python script is running right?
 
Because it's running in its own thread, other things seemed to work at the same time when I tested it.
 
yeah, that's what I supposed as it was threaded... thanks a lot! Really kind of you to have spend your time helping me like you did!
I will update and close the SO page when I'll be back from my appointment... Thank you again.
 

last day (14 days later) »