Launching a Writer document from Python

I would like to open a Writer document from a Python script that I can close reliably. Subprocess.call() opens the document fine, but I cannot close it. The basic idea is to pop open a window with a file generated from a template. When the user regenerates the file, Python closes the window and opens the new file. Is this possible?

Thanks Reuben

Does your call() routine give you access to the newly created Frame/Component?
Does your script belong to an instance under LibO? You need access to the StarDesktop service.
I think you need not to start an arbitrary subprocess, but to use something like

theOtherComponent = StarDesktop.LoadComponentFromURL(theURLformattedFilePathName, parameters)

and later the Store and/or the StoreAsURL and the Close methods of the Component.

subprocess.call() simply does not have a reliable pid or anything. Mostly because the soffice.bin might be running already or might be closed from a different process.

hallo

to get Access to the soffice-process you have to run soffice in socket-mode or pipe-mode.
see this Answer

Could you give me a small example that opens/shows the file ‘/home/reuben/test.odt’ , waits three seconds, and then closes it again? I am still totally lost in the connection between Python and Libreoffice.

Ok, got it. I was baffled by the lack of doc.show() or similar. Vastly different from Gtk, anyway.