Graphics Reference
In-Depth Information
Connecting the actions
You might have noticed that none of the menu commands and toolbar icons do anything
yet—even the
Quit
command doesn't work. Before our actions do anything, we have to
connect them to the appropriate method. To do this, add the following to your
MapEx-
plorer.__init__()
method, immediately after the call to
setupUi()
:
self.connect(self.actionQuit,
SIGNAL("triggered()"), qApp.quit)
self.connect(self.actionShowBasemapLayer,
SIGNAL("triggered()"),
self.showBasemapLayer)
self.connect(self.actionShowLandmarkLayer,
SIGNAL("triggered()"),
self.showLandmarkLayer)
self.connect(self.actionZoomIn,
SIGNAL("triggered()"), self.zoomIn)
self.connect(self.actionZoomOut,
SIGNAL("triggered()"), self.zoomOut)
self.connect(self.actionPan,
SIGNAL("triggered()"), self.setPanMode)
self.connect(self.actionExplore,
SIGNAL("triggered()"),
self.setExploreMode)
We're connecting our
Quit
action to the
qApp.quit()
method. For the other actions,
we'll be calling methods within our
MapExplorer
class itself. Let's define some place-
holders for these methods:
def showBasemapLayer(self):
pass
def showLandmarkLayer(self):
pass
def zoomIn(self):
pass