Scribus Forums

Scribus => Scripts and Plugins => Topic started by: kincza on August 12, 2014, 06:56:27 pm

Title: close scribus by python script
Post by: kincza on August 12, 2014, 06:56:27 pm
Hello,

I made an python script to convert sla files to eps. This function works as a service. After the scribus has started the script is loaded with an autohotkey script.
My script is listening on an ActiveMQ queue. If the message is arrived to the queue, the script convert the sla file (was specified in the message) to eps format.
Howewer sometimes (after hundred of messages or after 3-4 days) the scribus is slower and slower. I thought that it would be better if I restart the scribus after 100 messages but I don't know how can I close the scribus from the python script.
It is possible?

Regards,

kincza
Title: Re: close scribus by python script
Post by: Astroman Pete on September 08, 2014, 10:24:38 pm
Yes. I'd do it with Qt's QApplication object. You'll need a PyQt installation of the same version as Scribus' Qt installation.

When I run this as an extension script, it exits Scribus:

Code: [Select]
import site

# Replace with site.getsitepackages(), site.getusersitepackages()
# from you're system Python installation.
SITE_DIRS = ['C:/Python27', 'C:/Python27/lib/site-packages', ]

for p in SITE_DIRS:
    site.addsitedir(p)

import PyQt4.QtGui as gui

app = gui.QApplication.instance()
app.exit(0)