Graphics Reference
In-Depth Information
self.actionSetEndPoint.setEnabled(True)
self.actionFindShortestPath.setEnabled(True)
We'll also need to add a call to adjustActions() in our main() function after the
call to setPanMode() :
window.adjustActions()
With the track editing mode implemented, the user can click on the Edit toolbar icon to
enter the track editing mode, and click on it again to leave that mode. Of course, we can't
make any changes yet, but the code itself is in place.
There's one more feature we'd like to add to our application; if the user makes some
changes to the track layer and then tries to quit the application, we'd like to give the user
the chance to save their changes. To do this, we'll implement the quit() method, which
we linked to the actionQuit action:
def quit(self):
if self.editing and self.modified:
reply = QMessageBox.question(self, "Confirm",
"Save Changes?",
QMessageBox.Yes |
QMessageBox.No |
QMessageBox.Cancel,
QMessageBox.Yes)
if reply == QMessageBox.Yes:
self.curEditedLayer.commitChanges()
elif reply == QMessageBox.No:
self.curEditedLayer.rollBack()
if reply != QMessageBox.Cancel:
qApp.quit()
else:
qApp.quit()
This is very similar to the part of the setEditMode() method that lets the user leave
the track editing mode, except that we call qApp.quit() to quit the application at the
end. We have one more method to define, which intercepts an attempt to close the window
Search WWH ::




Custom Search