[Qgis-user] Close QGIS via PyQGIS

Ujaval Gandhi ujaval at spatialthoughts.com
Wed May 13 08:11:34 PDT 2020


The way to do this is to launch a new QGIS instance without GUI, run your
pyqgis code and then exit.

qgs = QgsApplication([], False)
qgs.initQgis()

.<your pyqgis code>

qgs.exitQgis()

See a full example at
https://courses.spatialthoughts.com/pyqgis-in-a-day.html#writing-standalone-python-scripts
[image: Logo] <https://spatialthoughts.com/>
Ujaval Gandhi
Spatial Thoughts
mobile: +91-8095684687
email: ujaval at spatialthoughts.com
[image: LinkedIn icon] <https://www.linkedin.com/in/spatialthoughts/>  [image:
Twitter icon] <https://twitter.com/spatialthoughts>
Subscribe to our newsletter http://bit.ly/spatialthoughts-newsletter


On Wed, May 13, 2020 at 7:48 PM Christoph Jung <jagodki.cj at gmail.com> wrote:

> Hello everyone,
>
> I want to create a scheduled task with opening QGIS, run a python script
> and close the application at the end. Is it possible to close the current
> QGIS application via PyQGIS? Or does anybody knows a better way to close
> QGIS at the end of the task?
>
> Sincerely,
> Christoph
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20200513/cb6a741c/attachment.html>


More information about the Qgis-user mailing list