Graphics Reference
In-Depth Information
The forestTrails.py module
This module defines the main program for the ForestTrails application. It looks very simil-
ar to the lex.py module we defined in Chapter 5 , Using QGIS in an External Applica-
tion . Create your forestTrails.py file, and enter the following import statements
into it:
import os, os.path, sys
from qgis.core import *
from qgis.gui import *
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from ui_mainWindow import Ui_MainWindow
import resources
from constants import *
from mapTools import *
Next, we want to define the main window for our application in a class, which we will call
ForestTrailsWindow . This is where the bulk of the application code will be imple-
mented; this class will get quite complicated, but we're going to start easy and just define
the window itself, and have empty placeholder methods for all the toolbar actions.
Let's define the class itself and the __init__() method to initialize a new window:
class ForestTrailsWindow(QMainWindow, Ui_MainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
self.connect(self.actionQuit, SIGNAL("triggered()"),
self.quit)
self.connect(self.actionZoomIn,
SIGNAL("triggered()"),
self.zoomIn)
Search WWH ::




Custom Search