Graphics Reference
In-Depth Information
The ui_mainWindow.py module
This is the last module we need to define for our initial implementation of the ForestTrails
system. As in the Lex application, this module defines a Ui_MainWindow class, which
implements the application's user interface, and defines QAction objects for the various
menu and toolbar items. We'll start by importing the modules that our class will need:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import resources
Next, we'll define the Ui_MainWindow class and the setupUi() method that will do
all the work:
class Ui_MainWindow(object):
def setupUi(self, window):
The first part of the setupUi() method sets the title for the window, creates a cent-
ralWidget instance variable to hold the map view, and initializes the application's menus
and toolbar:
window.setWindowTitle("Forest Trails")
self.centralWidget = QWidget(window)
self.centralWidget.setMinimumSize(800, 400)
window.setCentralWidget(self.centralWidget)
self.menubar = window.menuBar()
self.fileMenu = self.menubar.addMenu("File")
self.mapMenu = self.menubar.addMenu("Map")
self.editMenu = self.menubar.addMenu("Edit")
self.toolsMenu = self.menubar.addMenu("Tools")
self.toolBar = QToolBar(window)
window.addToolBar(Qt.TopToolBarArea, self.toolBar)
Next, we want to define all the QAction objects for the various toolbar and menu items.
For each action, we'll define the action's icon and keyboard shortcut, and check whether or
not the action is checkable (that is, stays on when the user clicks on it):
Search WWH ::




Custom Search