Graphics Reference
In-Depth Information
Adjusting the toolbar actions
Now that we've finished creating all the necessary map tools and instance variables, we can
finally implement the rest of the adjustActions() method to adjust the toolbar and
menu items to reflect the current state of the system. Firstly, we want to change the final
line of this method so that the Find Shortest Path action is only enabled if the start and
end points have both been set:
self.actionFindShortestPath.setEnabled(
self.curStartPt != None andself.curEndPt != None)
In the final part of this method, we'll want to find the action that is associated with the cur-
rent map tool and check that action, while unchecking all the others. To do this, add the fol-
lowing code to the end of your adjustActions() method:
curTool = self.mapCanvas.mapTool()
self.actionPan.setChecked(curTool == self.panTool)
self.actionEdit.setChecked(self.editing)
self.actionAddTrack.setChecked(
curTool == self.addTrackTool)
self.actionEditTrack.setChecked(
curTool == self.editTrackTool)
self.actionDeleteTrack.setChecked(
curTool == self.deleteTrackTool)
self.actionGetInfo.setChecked(curTool ==
self.getInfoTool)
self.actionSetStartPoint.setChecked(
curTool == self.selectStartPointTool)
self.actionSetEndPoint.setChecked(
curTool == self.selectEndPointTool)
self.actionFindShortestPath.setChecked(False)
Tip
Note that this code should go outside the if...else statement that you've already
entered in this method.
Search WWH ::




Custom Search