Graphics Reference
In-Depth Information
Adding the user interface
Now that our program is running, we can start implementing the user interface (UI). A typ-
ical PyQt application will make use of Qt Designer to store the application's UI in a tem-
plate file, which is then compiled into a Python module for use within your application.
As it would take many pages to describe how to use Qt Designer to lay out our window
with its toolbar and menus, we're going to cheat and create our user interface directly with-
in Python. At the same time, however, we'll create our UI module as if it was created using
Qt Designer; this keeps our application's UI separate, and also shows how our application
would work if we were to use Qt Designer to design our user interface.
Create a new module called ui_explorerWindow.py , and type the following code in-
to this module:
from PyQt4 import QtGui, QtCore
import resources
class Ui_ExplorerWindow(object):
def setupUi(self, window):
window.setWindowTitle("Landmark Explorer")
self.centralWidget = QtGui.QWidget(window)
self.centralWidget.setMinimumSize(800, 400)
window.setCentralWidget(self.centralWidget)
self.menubar = window.menuBar()
self.fileMenu = self.menubar.addMenu("File")
self.viewMenu = self.menubar.addMenu("View")
self.modeMenu = self.menubar.addMenu("Mode")
self.toolBar = QtGui.QToolBar(window)
window.addToolBar(QtCore.Qt.TopToolBarArea,
self.toolBar)
self.actionQuit = QtGui.QAction("Quit", window)
self.actionQuit.setShortcut(QtGui.QKeySequence.Quit)
Search WWH ::




Custom Search