[QGIS-Developer] pyggis - standalone

Kasper rapzak at gmail.com
Sun Jun 24 08:18:31 PDT 2018


Hi,

I have finally made an application there can load and show a OSM in a
window as a standalone application both on windows and a raspberry pi
(compiled from source)

I had some issues getting the map showed correct.

This code here is working:
import sys
import os

if not os.name == 'nt':

sys.path.append('/home/pi/.local/share/QGIS/QGIS3/profiles/default/python')

sys.path.append('/home/pi/.local/share/QGIS/QGIS3/profiles/default/python/plugins')
    sys.path.append('/home/pi/apps/share/qgis/python/plugins')
    sys.path.append("/home/pi/apps/share/qgis/python")
    sys.path.append("/usr/lib/python3/dist-packages/IPython/extensions")


from qgis.core import QgsApplication
from PyQt5.QtWidgets import QApplication
from window_class import OurMainWindow
from graph_class import main_graph

if os.name == 'nt':
    os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = r"C:\Program Files\QGIS
3.0\apps\Qt5\plugins\platforms"
    os.environ["GDAL_DATA"] = r"C:\Program Files\QGIS 3.0\share\epsg_csv"
    data_file = r"C:\Users\Kasper\My Documents\LiClipse
Workspace\gis_test\source\kor_ind_mod_terminal.ood"
    QgsApplication.setPrefixPath(r"C:\Program Files\QGIS 3.0\apps\qgis",
True)
else:
    QgsApplication.setPrefixPath(r"/home/pi/apps", True)
    data_file = r"kor_ind_mod_terminal.ood"

app = QApplication([])
QgsApplication.initQgis()

gp = main_graph()
mw = OurMainWindow(gp,data_file)
mw.show()

app.exec_()
mw = None
QgsApplication.exitQgis()

However i am wondering why i have to use the QApplication([]) instead  app
= QgsApplication([]) ?

If i use the QgsApplication the map is not shown.

Could someone explain why and if it is the purpose.

Maybe some Path there is overwritten from system?

/Kasper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180624/b9aa8b8a/attachment.html>


More information about the QGIS-Developer mailing list