I am starting to learn to develop stand alone QGIS applications from a book called 'Building Mapping Applications with QGIS'.
Here's the python code stated in the book (lex.py):
import os, os.path, sys
from qgis.core import *
from qgis.gui import *
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class MapExplorer(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setWindowTitle("Landmark Explorer")
self.resize(800, 400)
def main():
QgsApplication.setPrefixPath(os.environ['QGIS_PREFIX'], True)
QgsApplication.initQgis()
app = QApplication(sys.argv)
window = MapExplorer()
window.show()
window.raise_()
app.exec_()
app.deleteLater()
QgsApplication.exitQgis()
if __name__ == "__main__":
main()
Batch file (run.bat):
SET OSGEO4W_ROOT=C:\OSGeo4W64
SET QGIS_PREFIX=%OSGEO4W_ROOT%\apps\qgis
SET PATH=%QGIS_PREFIX%\bin;%OSGEO4W_ROOT%\bin;%PATH%
SET PYTHONPATH=%QGIS_PREFIX%\python;%PYTHONPATH%
SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python27
python lex.py
