100% found this document useful (1 vote)
18 views

GUI Programming with Python QT Edition Boudewijn Rempt download

The document is a comprehensive guide to GUI programming using Python and the Qt framework, authored by Boudewijn Rempt. It covers installation, programming fundamentals, and practical application development, including the use of the BlackAdder IDE and PyQt. The content is structured into sections that detail various concepts, tools, and techniques necessary for effective GUI programming.

Uploaded by

nattyeikengr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
18 views

GUI Programming with Python QT Edition Boudewijn Rempt download

The document is a comprehensive guide to GUI programming using Python and the Qt framework, authored by Boudewijn Rempt. It covers installation, programming fundamentals, and practical application development, including the use of the BlackAdder IDE and PyQt. The content is structured into sections that detail various concepts, tools, and techniques necessary for effective GUI programming.

Uploaded by

nattyeikengr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

GUI Programming with Python QT Edition Boudewijn

Rempt download

https://ebookname.com/product/gui-programming-with-python-qt-
edition-boudewijn-rempt/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Rapid GUI Programming with Python and Qt 1st Edition


Mark Summerfield

https://ebookname.com/product/rapid-gui-programming-with-python-
and-qt-1st-edition-mark-summerfield/

Programming ArcGIS with Python Cookbook 2nd Edition


Eric Pimpler

https://ebookname.com/product/programming-arcgis-with-python-
cookbook-2nd-edition-eric-pimpler/

Game Programming With Python Game Development Series


1st Edition Riley

https://ebookname.com/product/game-programming-with-python-game-
development-series-1st-edition-riley/

Empire of Ancient Egypt Wendy Christensen

https://ebookname.com/product/empire-of-ancient-egypt-wendy-
christensen/
The Atmosphere and Ocean A Physical Introduction Third
Edition Neil C. Wells(Auth.)

https://ebookname.com/product/the-atmosphere-and-ocean-a-
physical-introduction-third-edition-neil-c-wellsauth/

Global Health Watch 3 An Alternative World Health


Report 3rd Edition Amit Sengupta

https://ebookname.com/product/global-health-watch-3-an-
alternative-world-health-report-3rd-edition-amit-sengupta/

All s Well That Ends Well Webster s French Thesaurus


Edition William Shakespeare

https://ebookname.com/product/all-s-well-that-ends-well-webster-
s-french-thesaurus-edition-william-shakespeare/

Irish Politics and Social Conflict in the Age of the


American Revolution 1st Edition Maurice R. O'Connell

https://ebookname.com/product/irish-politics-and-social-conflict-
in-the-age-of-the-american-revolution-1st-edition-maurice-r-
oconnell/

Self Healing Composites Shape Memory Polymer Based


Structures 1st Edition Guoqiang Li

https://ebookname.com/product/self-healing-composites-shape-
memory-polymer-based-structures-1st-edition-guoqiang-li/
Encyclopedia of law enforcement 1st Edition Larry E.
Sullivan

https://ebookname.com/product/encyclopedia-of-law-
enforcement-1st-edition-larry-e-sullivan/
GUI Programming with Python:
QT Edition

Boudewijn Rempt
GUI Programming with Python: QT Edition
by Boudewijn Rempt

GUI Programming with Python: QT Edition Edition


Published July 2001
Copyright © 2001 by Commandprompt, Inc

Copyright (c) 2001 by Command Prompt, Inc. This material may be distributed only subject to the terms and
conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at
http://www.opencontent.org/openpub/).
‘Distribution of substantively modified versions of this document is prohibited without the explicit permission of the
copyright holder.’ to the license reference or copy.
‘Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior
permission is obtained from the copyright holder.’ to the license reference or copy.

Although every reasonable effort has been made to incorporate accurate and useful information into this book, the
copyright holders make no representation about the suitability of this book or the information therein for any purpose.
It is provided “as is” without expressed or implied warranty.
Dedication
This book is dedicated to Irina.
6
Table of Contents
Preface.....................................................................................................................23
1. Who is using PyQt .......................................................................................24
2. For whom is this book intended...................................................................24
3. How to read this book ..................................................................................25
4. Conventions .................................................................................................26
5. Acknowledgments........................................................................................27
1. Introduction ........................................................................................................29
1.1. Python .......................................................................................................30
1.2. GUI programming with Python ................................................................33
1.3. About the BlackAdder IDE.......................................................................35
I. Introduction to the BlackAdder IDE................................................................37
2. Installation....................................................................................................39
2.1. Installing BlackAdder .......................................................................39
2.1.1. Windows ................................................................................39
2.1.2. Linux ......................................................................................40
2.2. Installing sip and PyQt without BlackAdder ....................................41
2.2.1. Building from source on Linux..............................................42
2.2.1.1. Problems with compilation .........................................43
2.2.2. Windows ................................................................................44
3. Interface .......................................................................................................47
3.1. Menubar ............................................................................................48
3.2. Toolbars.............................................................................................48
3.2.1. File toolbar .............................................................................49
3.2.2. Edit toolbar.............................................................................49
3.2.3. Execution toolbar ...................................................................49
3.2.4. Layout manager toolbar .........................................................50
3.2.5. Widgets ..................................................................................50
3.2.6. Help........................................................................................50
3.2.7. Pointer toolbar........................................................................50
3.2.8. More widget toolbars .............................................................51
3.3. Project management..........................................................................51
3.4. BlackAdder Configuration ................................................................53
3.5. Editing...............................................................................................55
3.6. Python shell.......................................................................................55

7
3.7. Conclusion ........................................................................................56
4. Introduction to Python .................................................................................57
4.1. Programming fundamentals ..............................................................57
4.2. The Rules ..........................................................................................61
4.2.1. Objects and references ...........................................................61
4.2.2. Formatting..............................................................................62
4.2.3. Keywords ...............................................................................63
4.2.4. Literals ...................................................................................64
4.2.5. Methods and functions...........................................................64
4.2.6. High level datatypes...............................................................65
4.3. Constructions ....................................................................................66
4.3.1. Looping ..................................................................................66
4.3.2. Branching...............................................................................69
4.3.3. Exceptions..............................................................................70
4.3.4. Classes....................................................................................71
4.4. Conclusion ........................................................................................72
5. Debugging....................................................................................................73
5.1. Running scripts .................................................................................76
5.2. Setting breakpoints............................................................................76
5.3. Stepping along ..................................................................................78
5.4. Debugging Techniques......................................................................81
5.4.1. Avoid changing your code .....................................................81
5.4.2. Gather data .............................................................................81
5.4.3. Minimal examples..................................................................82
5.5. If all else fails....................................................................................82
II. PyQt fundamentals ...........................................................................................85
6. Qt Concepts..................................................................................................87
6.1. Python, Qt and PyQt .........................................................................87
6.2. As simple as they come.....................................................................88
6.3. A better Hello World.........................................................................91
6.4. Designing forms................................................................................96
6.5. Conclusion ......................................................................................101
7. Signals and Slots in Depth .........................................................................103
7.1. The concept of signals and slots .....................................................103
7.1.1. Callbacks..............................................................................104
7.1.2. Action registry .....................................................................106
7.1.3. Signals and slots...................................................................108

8
7.2. Connecting with signals and slots...................................................110
7.3. Disconnecting .................................................................................120
7.4. A parser-formatter using signals and slots......................................127
7.5. Conclusion ......................................................................................137
8. String Objects in Python and Qt ................................................................139
8.1. Introduction.....................................................................................139
8.2. String conversions...........................................................................140
8.3. QCString — simple strings in PyQt ...............................................142
8.4. Unicode strings ...............................................................................146
8.4.1. Introduction to Unicode .......................................................147
8.4.2. Python and Unicode.............................................................148
8.4.2.1. String literals.............................................................149
8.4.2.2. Reading from files.....................................................151
8.4.2.3. Other ways of getting Unicode characters into Python
string objects ..................................................................153
8.4.3. Qt and Unicode ....................................................................156
9. Python Objects and Qt Objects ..................................................................159
9.1. Pointers and references ...................................................................159
9.2. Circular references ..........................................................................160
9.3. Qt objects, Python objects and shadow objects ..............................161
9.4. References and ownership ..............................................................163
9.5. Other C++ objects...........................................................................173
9.6. Connecting signals and slots...........................................................173
9.7. Object and class introspection ........................................................175
10. Qt Class Hierarchy...................................................................................177
10.1. Hierarchy.......................................................................................177
10.2. Base classes...................................................................................179
10.3. Application classes........................................................................182
10.3.1. Multiple document windows with QWorkspace................185
10.4. Widget foundations: QWidget ......................................................187
10.4.1. QColor................................................................................189
10.4.2. QPixmap, QBitmap and QImage .......................................190
10.4.3. QPainter .............................................................................191
10.4.4. QFont .................................................................................193
10.5. Basic widgets ................................................................................195
10.5.1. QFrame ..............................................................................197
10.5.2. QPushButton ......................................................................197

9
10.5.3. QLabel................................................................................199
10.5.4. QRadioButton ....................................................................202
10.5.5. QCheckBox........................................................................203
10.5.6. QListBox............................................................................204
10.5.7. QComboBox ......................................................................206
10.5.8. QLineEdit...........................................................................207
10.5.9. QMultiLineEdit..................................................................207
10.5.10. QPopupMenu ...................................................................207
10.5.11. QProgressBar ...................................................................207
10.5.12. QSlider and other small fry..............................................208
10.6. Advanced widgets .........................................................................209
10.6.1. QSimpleRichText, QTextView and QTextBrowser ...........209
10.6.2. QTextEdit ...........................................................................209
10.6.3. QListView and QListViewItem..........................................210
10.6.4. QIconView and QIconViewItem........................................211
10.6.5. QSplitter .............................................................................212
10.6.6. QCanvas, QCanvasView and QCanvasItems .....................212
10.6.7. QTable, QTableItem and QTableView (or QGridView).....213
10.7. Layout managers...........................................................................213
10.7.1. Widget sizing: QSizePolicy ...............................................215
10.7.2. Groups and frames .............................................................216
10.7.2.1. QHBox ....................................................................216
10.7.2.2. QVBox ....................................................................216
10.7.2.3. QGrid ......................................................................216
10.7.2.4. QGroupBox.............................................................216
10.7.3. QLayout .............................................................................217
10.7.4. QBoxLayout and children..................................................217
10.7.5. QGridLayout ......................................................................217
10.7.6. setGeometry .......................................................................220
10.8. Dialogs and Standard Dialogs.......................................................221
10.8.1. QDialog..............................................................................221
10.8.2. QMessageBox....................................................................221
10.8.3. QTabDialog........................................................................227
10.8.4. QWizard .............................................................................227
10.8.5. QFileDialog........................................................................227
10.8.6. QFontDialog ......................................................................228
10.8.7. QColorDialog.....................................................................229

10
10.8.8. QInputDialog .....................................................................230
10.8.9. QProgressDialog ................................................................230
10.9. Qt Utility classes and their Python equivalents ............................230
10.9.1. High level data structures...................................................235
10.9.2. Files and other IO...............................................................238
10.9.3. Date and time .....................................................................239
10.9.4. Mime ..................................................................................240
10.9.5. Text handling......................................................................241
10.9.6. Threads...............................................................................242
10.9.7. URL’s .................................................................................244
10.9.8. Qt modules that overlap with Python modules ..................245
11. Qt Designer, BlackAdder and uic ............................................................249
11.1. Introduction...................................................................................249
11.1.1. Starting out with the designer module ...............................249
11.1.2. Creating a design................................................................253
11.1.2.1. Grouping widgets....................................................253
11.1.2.2. Layout management................................................254
11.1.2.3. Tab order and accelerators ......................................254
11.2. Advanced Designer topics ............................................................256
11.2.1. Defining signals and slots in Designer...............................256
11.2.2. Adding your own widgets ..................................................259
11.2.3. Layout management...........................................................262
11.2.3.1. The Horizontal Layout Manager.............................264
11.2.3.2. The Vertical Layout Manager .................................264
11.2.3.3. The Grid Layout Manager ......................................264
11.2.3.4. The Spacer object....................................................265
11.2.3.5. What widgets can do to get the space they want.....265
11.2.3.6. Creating a complex form ........................................266
11.2.4. Generating and using Python code with pyuic ..................268
11.2.5. Generating C++ code with uic ...........................................270
III. Creating real applications with PyQt ..........................................................273
12. Application Frameworks..........................................................................275
12.1. Architecture: models, documents and views.................................275
12.1.1. A document-view framework ............................................277
12.2. Macro languages ...........................................................................284
12.3. Project layout ................................................................................284
13. Actions: menus, toolbars and accelerators...............................................287

11
13.1. Actions ..........................................................................................287
13.2. Menus............................................................................................291
13.3. Toolbars.........................................................................................292
13.4. Keyboard accelerators...................................................................294
13.5. Setting an application icon............................................................295
14. Automatic testing with PyUnit ................................................................297
14.1. About unittests ..............................................................................297
14.2. Starting out....................................................................................299
14.3. A first testcase ...............................................................................300
14.4. Collecting tests in a test suite........................................................302
14.5. A more complicated test ...............................................................303
14.6. Large projects................................................................................306
14.7. Testing signals and slots................................................................309
14.8. Conclusion ....................................................................................312
15. A More Complex Framework: Multiple Documents, Multiple Views ....315
15.1. Introduction...................................................................................315
15.2. Document/View Manager .............................................................319
15.3. The Document Manager ...............................................................325
15.4. Document......................................................................................332
15.5. View ..............................................................................................334
15.6. The actual application ...................................................................335
15.7. Conclusion ....................................................................................348
16. User Interface Paradigms .........................................................................349
16.1. Tabbed documents ........................................................................349
16.2. Back to the MDI windows ............................................................353
16.3. A row of split windows.................................................................354
16.4. A stack of documents....................................................................355
16.5. A more complex view management solution................................357
16.6. Conclusion ....................................................................................360
17. Creating Application Functionality..........................................................363
17.1. Introduction...................................................................................363
17.1.1. Giving the project a name ..................................................363
17.2. The view........................................................................................363
17.3. The document................................................................................368
17.4. Saving and loading documents .....................................................370
17.4.1. Loading ..............................................................................370
17.4.2. Saving ................................................................................371

12
17.5. Undo, redo and other editing functions.........................................372
17.6. Conclusion ....................................................................................378
18. Application Configuration .......................................................................379
18.1. Platform differences......................................................................379
18.2. The Python way of handling configuration settings .....................380
18.3. Implementing configurations settings for Kalam..........................381
18.3.1. Handling configuration data in your application ...............381
18.3.2. Saving and loading the configuration data.........................384
18.3.3. Using configuration data from the application...................386
18.3.3.1. Font settings ............................................................387
18.3.3.2. Window geometry ...................................................387
18.3.3.3. Determining the widget style ..................................389
18.3.3.4. Setting the viewmanager.........................................391
18.3.4. Catching the changes when the application closes ............393
18.4. Settings in Qt 3.0 ..........................................................................394
18.5. Conclusion ....................................................................................397
19. Using Dialog Windows ............................................................................399
19.1. Modal: a preferences dialog..........................................................399
19.1.1. Designing the dialog ..........................................................399
19.1.2. Creating the settings dialog window..................................401
19.1.3. Calling the settings dialog window....................................412
19.2. Non-modal: Search and replace ....................................................418
19.2.1. Design ................................................................................418
19.2.2. Integration in the application .............................................419
19.2.3. Implementation of the functionality...................................422
19.3. Conclusion ....................................................................................435
20. A Macro Language for Kalam .................................................................437
20.1. Executing Python code from Python ............................................437
20.1.1. Playing with eval() .........................................................439
20.1.2. Playing with exec..............................................................440
20.1.3. Playing with execfile() .................................................442
20.2. Integrating macros with a GUI .....................................................443
20.2.1. Executing the contents of a document ...............................443
20.2.2. startup macros ....................................................................452
20.3. Creating a macro API from an application ...................................453
20.3.1. Accessing the application itself .........................................454
20.3.2. Accessing application data.................................................456

13
20.3.3. Accessing and extending the GUI......................................456
20.3.4. Kalam rivals Emacs: an Eliza macro .................................457
20.4. Conclusion ....................................................................................460
21. Drawing on Painters and Canvases ..........................................................461
21.1. Working with painters and paint devices ......................................461
21.1.1. A painting example ............................................................462
21.2. QCanvas ........................................................................................471
21.2.1. A simple Unicode character picker....................................473
21.2.1.1. The canvas...............................................................476
21.2.1.2. The view on the canvas ...........................................478
21.2.1.3. Tying the canvas and view together ........................480
21.3. Conclusion ....................................................................................484
22. Gui Design in the Baroque Age ...............................................................485
22.1. Types of gui customization ...........................................................485
22.2. Faking it with bitmaps ..................................................................486
22.3. Creating themes with QStyle ........................................................491
22.3.1. Designing the style.............................................................491
22.3.2. Setting up ...........................................................................492
22.3.3. A Qt 2 custom style............................................................493
22.3.4. Using styles from PyQt......................................................505
23. Drag and drop ..........................................................................................521
23.1. Handling drops..............................................................................521
23.2. Initiating drags ..............................................................................523
23.3. Conclusion ....................................................................................525
24. Printing.....................................................................................................527
24.1. The QPrinter class .....................................................................527
24.2. Adding printing to Kalam .............................................................528
24.3. Putting ink to paper.......................................................................530
24.4. Conclusion ....................................................................................531
25. Internationalizing an Application ............................................................533
25.1. Translating screen texts.................................................................533
26. Delivering your Application ....................................................................541
26.1. Introduction...................................................................................541
26.2. Packaging source ..........................................................................542
26.3. Starting with distutils. ...................................................................544
26.3.1. setup.py ..............................................................................544
26.3.2. MANIFEST.in....................................................................546

14
26.3.3. setup.cfg .............................................................................547
26.3.4. Creating the source distribution .........................................547
26.3.5. Installing a source archive..................................................550
26.4. Creating Unix RPM packages.......................................................550
26.5. Windows installers ........................................................................551
26.6. Desktop integration .......................................................................552
27. Envoi ........................................................................................................553
IV. Appendices .....................................................................................................555
A. Reading the Qt Documentation.................................................................557
B. PyQwt: Python Bindings for Qwt .............................................................563
B.1. NumPy............................................................................................563
B.2. PyQwt.............................................................................................568
C. First Steps with Sip ...................................................................................573
C.1. Introduction ....................................................................................573
C.2. How sip works................................................................................574
C.3. Creating .sip files............................................................................574
C.4. Things sip can’t do automatically ..................................................577
C.4.1. Handwritten code ................................................................577
C.4.2. Other limitations..................................................................580
C.5. Where to look to start writing your own wrappers/bindings..........580
C.6. Sip usage and syntax ......................................................................581
C.6.1. Usage...................................................................................581
C.6.1.1. Invocation, Command Line ......................................581
C.6.1.2. Limitations ...............................................................582
C.6.1.3. Files ..........................................................................582
C.6.1.3.1. Source Files ...................................................582
C.6.1.3.2. Files containing the wrapping .......................582
C.6.1.3.3. Intermediate Files..........................................583
C.6.1.3.4. Auxilliary Files..............................................584
C.6.1.4. .sip File Syntax.........................................................585
C.6.1.4.1. General rules .................................................585
C.6.1.4.2. Macros...........................................................585
C.7. Directives........................................................................................586
C.7.1. Documentation ....................................................................586
%Copying ..............................................................................586
%Doc......................................................................................587
%ExportedDoc.......................................................................587

15
C.7.2. Modules...............................................................................588
%Module................................................................................588
%Include ................................................................................589
%Import .................................................................................590
C.7.3. Conditional Elements ..........................................................590
%If..........................................................................................591
%End......................................................................................591
Version().................................................................................592
%Version ................................................................................593
%PrimaryVersions..................................................................594
%VersionCode........................................................................594
C.7.4. C++ and Header Code Sections ..........................................595
%HeaderCode ........................................................................595
%ExportedHeaderCode..........................................................596
%ExposeFunction ..................................................................596
%C++Code.............................................................................597
%MemberCode ......................................................................597
%VirtualCode.........................................................................598
%VariableCode ......................................................................598
C.7.5. Python Code Sections .........................................................599
%PythonCode ........................................................................599
%PrePythonCode ...................................................................599
C.7.6. Mapped Classes...................................................................600
%ConvertFromClassCode......................................................600
%ConvertToClassCode ..........................................................601
%CanConvertToClassCode....................................................601
%ConvertToSubClassCode ....................................................602
C.7.7. Special Python methods ......................................................602
PyMethods .............................................................................603
PyNumberMethods ................................................................604
PySequenceMethods ..............................................................604
PyMappingMethods...............................................................605
C.7.8. Other....................................................................................606
%Makefile ..............................................................................606
C.8. Accepted C++ / Qt constructs ........................................................606
C.9. SIPLIB Functions...........................................................................609
C.9.1. Public Support Functions ....................................................609

16
C.9.2. Information functions..........................................................609
sipGetCppPtr..........................................................................610
sipGetComplexCppPtr ...........................................................610
sipGetThisWrapper ................................................................611
sipIsSubClassInstance............................................................612
C.9.3. Conversions and argument parsing .....................................613
sipParseArgs...........................................................................614
sipConvertToCpp ...................................................................617
sipMapCppToSelf ..................................................................618
sipConvertToVoidPtr ..............................................................619
sipConvertFromVoidPtr .........................................................620
sipConvertFromBool..............................................................621
sipCheckNone ........................................................................622
sipBadVirtualResultType .......................................................623
sipBadSetType .......................................................................624
C.9.4. Ressource handling .............................................................625
sipReleaseLock ......................................................................625
sipAcquireLock......................................................................625
sipCondReleaseLock..............................................................626
sipCondAcquireLock .............................................................627
sipMalloc................................................................................628
sipFree....................................................................................629
C.9.5. Calling Python.....................................................................629
sipEvalMethod .......................................................................630
sipCallHook ...........................................................................630
C.9.6. Functions specifically for signals/slots................................631
sipEmitSignal.........................................................................631
sipConvertRx .........................................................................632
sipConnectRx.........................................................................634
sipGetRx ................................................................................635
sipDisconnectRx ....................................................................636
C.9.7. Private Functions .................................................................638
Bibliography .........................................................................................................639

17
18
List of Tables
1-1. GUI Toolkits for Python ...................................................................................33
7-1. Matrix of QObject.connect() combinations..............................................119
10-1. Qt and Python high-level datastructures.......................................................235
10-2. Qt and Python network classes.....................................................................245
C-1. C++ access specifiers and sip.........................................................................576

List of Figures
10-1. Qt Inheritance Hierarchy (only the most important classes) ........................177
10-2. Object Ownership Hierarchy ........................................................................179
20-1. Playing with eval() ....................................................................................439
20-2. Playing with exec ........................................................................................441
20-3. Playing with execfile() ...........................................................................442

List of Examples
1-1. Bootstrapping a Python application..................................................................31
6-1. hello1.py — hello world ...................................................................................89
6-2. hello2.py — a better hello world ......................................................................91
6-3. fragment from hello3.py ...................................................................................94
6-4. Fragment from hello5.py ..................................................................................94
6-5. Fragment from hello4.py ..................................................................................95
6-6. frmconnect.py ...................................................................................................97
6-7. dlgconnect.py — the subclass of the generated form .....................................100
7-1. A stupid button which is not reusable ............................................................103
7-2. A simple callback system ...............................................................................104
7-3. A central registry of connected widgets .........................................................106
7-4. Connecting a signal to a slot...........................................................................111
7-5. Connection a dial to a label with signals and slots .........................................113
7-6. Python signals and slots..................................................................................116
7-7. Python signals and slots with arguments ........................................................117
7-8. datasource.py — connecting and disconnecting signals and slots .................122

19
7-9. An XML parser with signals and slots ...........................................................128
8-1. qstring1.py — conversion from QString to a Python string.........................140
8-2. qstring2.py - second try of saving a QString to a file...................................141
8-3. empty.py - feeding zero bytes to a QCString..................................................143
8-4. null.py - empty and null QCStrings and Python strings .................................144
8-5. emptyqstring.py - feeding zero bytes to a QString .........................................146
8-6. Loading an utf-8 encoded text ........................................................................151
8-7. Building a string from single Unicode characters ..........................................153
8-10. uniqstring1.py - coercing Python strings into and from QStrings ................156
8-11. uniqstring2.py - coercing Python strings into and from QStrings ................157
9-1. refs.py - showing object references ................................................................160
9-2. circular.py - circululululular references..........................................................161
9-3. qtrefs1.py — about Qt reference counting .....................................................163
9-4. qtrefs2.py - keeping a Qt widget alive............................................................164
9-5. qtrefs3.py - Qt parents and children ...............................................................165
9-6. Eradicating a widget .......................................................................................166
9-7. children.py - getting the children from a single parent...................................167
9-8. Iterating over children.....................................................................................169
9-9. sigslot.py - a simple signals/slots implementation in Python, following the
Observer pattern.............................................................................................173
9-10. Object introspection using Qt .......................................................................175
9-11. Object introspection using Python................................................................176
10-1. event1.py - handling mouse events in PyQt..................................................180
10-2. action.py - Using a QAction to group data associated with user commands183
10-3. fragment from mdi.py - ten little scribbling windows..................................186
10-4. event2.py - using QWidget to create a custom, double-buffered drawing
widget.............................................................................................................187
10-5. snippet from event3.py - a peach puff drawing board ..................................190
10-6. fragment from action2.py - You cannot create a QPixmap before a
QApplication..................................................................................................192
10-7. buttons.py - Four pushbuttons saying ‘hello’. ..............................................198
10-8. label.py - a label associated with an edit control ..........................................199
10-9. radio.py - a group of mutually exclusive options .........................................202
10-10. listbox.py - A listbox where data can be associated with an entry .............204
10-11. tree.py - building a tree...............................................................................210
10-12. layout.py - two box layouts and adding and removing buttons dynamically to
a layout...........................................................................................................218

20
10-13. geometry.py - setting the initial size of an application ...............................220
10-14. dialogs.py - opening message and default dialogs boxes ...........................222
10-15. fragment from dialogs.py - opening a file dialog .......................................228
10-16. fragment from dialogs.py - opening a font dialog ......................................229
10-17. fragment from dialogs.py - opening a color dialog ....................................229
10-18. from dv_qt.py - using Qt utility classes......................................................231
10-19. fragment from db_python.py - using Python utility classes.......................233
10-20. Using QMimeSourceFactory (application.py)............................................241
10-21. thread1.py — Python threads without gui ..................................................242
10-22. Python threads and a PyQt gui window......................................................243
11-1. dlgcomplex.py — a subclass of frmcomplex.py ..........................................268
11-2. Setting default values....................................................................................270
12-1. A simple document-view framework ...........................................................277
12-2. Scripting an application is easy ....................................................................284
13-1. Defining a complex toggle action .................................................................288
15-1. A testcase for a document manager..............................................................319
15-2. The document manager class........................................................................325
15-3. The document class ......................................................................................332
15-4. The view class ..............................................................................................334
15-5. The application class ....................................................................................336
21-1. typometer.py - A silly type-o-meter that keeps a running count of how many
characters are added to a certain document and shows a chart of the typerate...
462
21-2. charmap.py - a Unicode character selection widget .....................................475
22-1. remote.py - remote control application.........................................................488
22-2. view.py - the main view of the remote control application ..........................489
22-3. button.py - the class that implements the pixmapped buttons ......................490
22-4. A Qt 2 custom style - a minimalist implementation of the classic Mac style in
PyQt. ..............................................................................................................493
22-5. Testing styles ................................................................................................506
23-1. Handling drop events....................................................................................521
23-2. Drag and drop ...............................................................................................524
25-1. Installing the translator .................................................................................538
26-1. README .....................................................................................................543
26-2. setup.py - a sample setup script ....................................................................544
26-3. MANIFEST.in ..............................................................................................546
C-1. Interface for QRegExp::match .......................................................................616

21
22
Preface
The main topic of this book is application development using PyQt, a library
extension to the Python programming language — a library that is meant to form
the basis for GUI programming. PyQt is free software, but there is also a
commercial IDE available, BlackAdder, that is specially written to assist working
with PyQt. I will show you the ins and outs of PyQt by developing a complete and
complex application.
Like most thirty–somethings who started programming in their teens, I’ve worked
with a lot of different technologies. I started with Sinclair Basic, going on to Turbo
Pascal and SNOBOL — I have developed for Windows in pure C, with Borland
Pascal and with Visual Basic. I’ve done my stretch with Oracle Forms, and served
as a Java developer. On Linux, I’ve wet my feet with Free Pascal, with C++, using
XForms and Qt. And just when I was getting fond of Qt and C++, I found out about
Python — a few years ago now. I found programming with PyQt to be a lot more
fun than anything else, and productive fun, too.
For sheer productivity, nothing beats Python and PyQt. And while there’s always
something new to learn or explore in Python, if you’re in the mood, it’s easy and
pleasant to write useful applications from the first day. No other programming
language or library has ever given me that.
So, when Cameron Laird, during a discussion on the comp.lang.python newsgroup
suggested that I’d write a book on this particular way of developing GUI
applications with Python, I started to think — and more than think. I started to
contact publishers, until one day Shawn Gordon of TheKompany brought me into
contact with Joshua Drake of Opendocs. I started writing text and code almost
immediately.
Joshua’s patience has been monumental — I should have written this book between
February and May, but it took me until November. All I can say for myself is that a
lot of effort has gone into the book. I discuss most of the concepts and classes of the
Qt library, which might be useful not only to Python developers, but also to C++
developers, and I have written a lot of example scripts.
Where Bruce Eckel (of Thinking in Java fame) favors small example programs
because they clearly illustrate the matter in hand, John Grayson in Python and
Tkinter argues that larger real-life applications are more useful because they don’t

23
Preface

hide the complexity that is a part of any programming effort.


Both are right, of course, so I decided to give you both small examples and one
really large one. Part I and II of this book concern themselves with concepts: here
the examples are small, often amounting to less than one page of code. Part III takes
you through the development of a complete, complex application. In this case an
editor, but one with a lot of extra features. I think it’s a very good way of learning
what developing complex applications entails - I spare you none of the nasty details
that software development entails.
I have tried to keep to a very clear style of coding, with few or none of the clever
hacks that are possible in Python — like adding the methods of one class to another,
or creating lists of function objects. The purpose is to tell you about writing real
applications using Python and Qt. Clever hacking has its place, but is best savored
on its own.
The emphasis of the book is also firmly on application development, not on creating
graphics per se — although several techniques are mentioned here and there that
have to do with creating charts and graphs.

1. Who is using PyQt


The combination of Python and Qt is extremely powerful, and is used in a wide
variety of applications. People are scripting OpenGL applications with it, creating
complex 3D models, animation applications, writing database applications, games,
utilities and hardware monitoring applications. It is used in open source projects,
but also by large companies, like Disney Television and Media. If you’re not
working on embedded software, hardware drivers or a new operating system,
chances are that PyQt is the right choice for you, too.

2. For whom is this book intended


This is the first book on Python and Qt. There have been quite a few books on C++
and Qt, but you would need to be fairly adept at mentally searching and replacing
C++ language constructs to be able to use those books for pleasure and profit if

24
Preface

your chosen language is Python. The same holds for the extensive html
documentation that comes with the C++ Qt library.
With the growing popularity of Python, PyQt and BlackAdder, people will start
using these tools who don’t want to translate C++ to Python to figure out what they
are supposed to do.
This is the first group of people for whom I’ve written this book: beginning software
developers who have chosen Python because it allows them to become productive
quickly with a language and an environment that have been designed to
accommodate ‘subject specialists’. That is, people who need to get an application
done to help them with their work, but who are not developers by profession.
Then there are the experienced developers, people who have been coding in Visual
Basic, Delphi or Java, and who, like the first group, now need something a lot more
productive and portable. They will be able to grasp the concepts quickly, but may
find a lot of use in the advanced code examples and the in-depth discussion of issues
particular to PyQt.
Another group of possible readers consists of C++ developers who have turned to
Python as a rapid prototyping language. Prototyping with the same GUI library they
will use for their final C++ application will give them a definite advantage, as most
of the prototype code will remain useful.
Finally there are people who are more experienced in Python than I am, but who
want to get acquainted with one of the best-designed GUI toolkits available for the
language—there is a lot of interesting content to be found in this book for them, too.
My aim in writing this book was to create a genuine vademecum for Python, PyQt
and GUI programming. If you keep referring to this book a year after you’ve
acquired it, if you can find the answer to most of your daily and quite a few of your
exceptional problems, and if you tend to keep this book in the vicinity of your desk,
then I will have succeeded.

3. How to read this book


Like ancient Gaul, this book is divided in three parts. The first part details the
installation of PyQt and of BlackAdder. Then the book takes you through a tour of
the interface of BlackAdder. You might want to read this part in order. There is also

25
Exploring the Variety of Random
Documents with Different Content
the coronation of King Edward VII. the claim was excluded from
the consideration of the Court of Claims under the royal
proclamation. The terms of the judgment on a further claim are
as follows: “The Court considers and adjudges that the lord
mayor has by usage a right, subject to His Majesty’s pleasure, to
attend the Abbey during the coronation and bear the crystal
mace.”

Bibliography.—The earliest description of London is that written


by the monk Fitzstephen in 1174 as an introduction to his life of
Archbishop Thomas à Becket. This was first printed by Stow in
his Survey. It was reprinted by Strype in his editions of Stow; by
Hearne in his edition of Leland’s Itinerary (vol. 8), by Samuel
Pegge in 1772, and elsewhere. The first history is contained in A
Survey of London by John Stow (1598, 1603). The author died
in 1605, and his work was continued by Anthony Munday and
others (1618, 1633) and in the next century by John Strype
(1720, 1754-1755). Stow’s original work was reprinted by W. J.
Thoms in 1842 and a monumental edition has been published by
C. L. Kingsford (Oxford, 1908).

The following are the most important of subsequent histories


arranged in order of publication; James Howell, Londinopolis
(1657); W. Stow, Remarks on London and Westminster (1722);
Robert Seymour (John Mottley), Survey of the Cities of London
and Westminster (1734, another edition 1753); William Maitland,
History of London (1739, other editions 1756, 1760, 1769,
continued by John Entick 1775); John Entick, A New and
Accurate History of London, Westminster, Southwark (1766);
The City Remembrancer, Narratives of the Plague 1665, Fire
1666 and Great Storm 1703 (1769); A New and Compleat
History and Survey, by a Society of Gentlemen (1770, revised by
H. Chamberlain, folio revised by W. Thornton 1784); J.
Noorthouck, A New History (1773); Walter Harrison, A New and
Universal History (1775); J. P. Malcolm, Londinium Redivivum or
an Ancient History and Modern Description of London (1803);
David Hughson (E. Pugh), London (1805-1809); B. Lambert,
History and Survey of London (1806); Henry Hunter, History of
London (1811); J. W. Abbott, History of London (1821); Thomas
Allen, History and Antiquities of London (1827-1829, continued
by Thomas Wright 1839); William Smith, A New History of
London (1833); Charles Mackay, A History of London (1838);
The History of London, illustrated by W. G. Fearnside (1838);
George Grant, A Comprehensive History of London (Dublin,
1849); John Timbs, Curiosities of London (1855, later editions
1855, 1868, 1875, 1876); Old London Papers, Archaeological
Institute (1867); W. J. Loftie, A History of London (1883); W. J.
Loftie, Historic Towns (London, 1887); Claude de la Roche
Francis, London, Historic and Social (Philadelphia, 1902); Sir
Walter Besant, The Survey of London (1902-1908)—Early
London, Prehistoric, Roman, Saxon and Norman (1908);
Medieval London, vol. 1, Historical and Social (1906), vol. 2,
Ecclesiastical (1906); London in the Time of the Tudors (1904);
London in the Time of the Stuarts (1903); London in the
Eighteenth Century (1902); H. B. Wheatley, The Story of London
[Medieval Towns] (London, 1904).

The following are some of the Chronicles of London which


have been printed, arranged in order of publication: R. Grafton,
Chronicle 1189-1558 (1809); R. Arnold, London Chronicle
(1811); A Chronicle of London from 1089 to 1483 written in the
Fifteenth Century (1827); William Gregory’s Chronicle of London,
1189-1469 (1876); Historical Collections of a Citizen of London,
edited by James Gairdner (Camden Society, 1876); Chronicles of
London [1200-1516], edited by C. L. Kingsford (Oxford, 1905).

Many books have been published on the government of


London, of which the following is a selection: City Law (1647,
1658); Lex Londinensis or the City Law (1680); W. Bohun,
Privilegia Londini (1723); Giles Jacob, City Liberties (1733); Laws
and Customs, Rights, Liberties and Privileges of the City of
London (1765); David Hughson, Epitome of the Privileges of
London (1816); George Norton, Commentaries on the History,
Constitution and Chartered Franchises of the City of London
(1829, 3rd ed. 1869); Munimenta Gildhallae Londoniensis, edited
by H. T. Riley—vol. 1, Liber Albus (1419), vol. 2, Liber
Custumarum (1859); Liber Albus: the White Book of the City of
London, translated by H. T. Riley (1861); H. T. Riley, Memorials
of London and London Life in the 13th, 14th and 15th centuries
(1868); De Antiquis Legibus Liber. Curante Thoma Stapleton
(Camden Society, 1846); Chronicles of the Mayors and Sheriffs
of London 1188-1274, translated from the Liber de Antiquis
Legibus by H. T. Riley. French Chronicle of London 1259-1343
(1863); Analytical Index to the Series of Records known as the
Remembrancia 1579-1664 (1888); Calendar of Letter-Books
[circa 1275-1399] preserved among the Archives of the
Corporation of London at the Guildhall, edited by Reginald R.
Sharpe, D.C.L. (1899-1907); W. and R. Woodcock, Lives of Lord
Mayors (1846); J. F. B. Firth, Municipal London (1876); Walter
Delgray Birch, Historical Charters and Constitutional Documents
of the City of London (1884, 1887); J. H. Round, The Commune
of London and other Studies (1899); Reginald R. Sharpe,
London and the Kingdom; a History derived mainly from the
Archives at Guildhall (1894); G. L. Gomme, The Governance of
London. Studies on the Place occupied by London in English
Institutions (1907); Alfred B. Beaven, The Aldermen of the City
of London temp. Henry III. (1908).

In connexion with the government of London may be noted


works on the following: Inns of Court. William Herbert,
Antiquities of the Inns of Court and Chancery (1804); Robert P.
Pearce, History (1848). Artillery Company, Anthony Highmore,
History of the Hon. Artillery Co. of London to 1802 (1804); G. A.
Raikes, History of the Hon. Artillery Co. (1878). William Herbert
published in 1837 History of the Twelve great Livery Companies
of London, and in 1869 Thomas Arundell published Historical
Reminiscences of the City and its Livery Companies. Since then
have appeared The Livery Companies of the City of London, by
W. Carew Hazlitt (1892); The City Companies of London, by P. H.
Ditchfield (1904); The Gilds and Companies of London, by
George Unwin (1908). Separate histories have been published of
the chief London companies.

The following are some of the chief works connected with the
topography of London: Thomas Pennant, Of London (1790,
1793, 1805, 1813, translated into German 1791); John T. Smith,
Antient Topography of London (1815); David Hughson [E.
Pugh], Walks through London (1817); London (edited by Charles
Knight 1841-1844, reprinted 1851, revised by E. Walford 1875-
1877); J. H. Jesse, Literary and Historical Memorials of London
(1847); Leigh Hunt, The Town, its Memorable Character and
Events (1848, new ed. 1859); Peter Cunningham, A Handbook
of London past and present (1849, 2nd ed. 1850, enlarged into
a new work in 1891); Henry B. Wheatley, London past and
present; Vestiges of Old London, etchings by J. W. Archer
(1851); A New Survey of London (1853); G. W. Thornbury,
Haunted London (1865, new ed. by E. Walford 1880); Old and
New London, vols. i.-ii. by G. W. Thornbury, vols. iii.-vi. by
Edward Walford (1873-1878); Walter Besant, London,
Westminster, South London, East London (1891-1902); East
London Antiquities, edited by Walter A. Locks (East London
Advertiser, 1902); Philip Norman, London vanished and
vanishing (1905); Records of the London Topographical Society;
Monographs of the Committee for the Survey of the Memorials
of Greater London.

The following books on the population of London have been


published: John Graunt, Natural and Political Observations on
the Bills of Mortality (1661, other editions 1662, 1665, 1676);
Essay in Political Arithmetick (1683); Five Essays on Political
Arithmetick (1687); Several Essays in Political Arithmetick (1699,
1711, 1751, 1755); Essay concerning the Multiplication of
Mankind (1682, 1683, 1686), all by Sir William Petty; Corbyn
Morris, Observations on the past Growth and present State of
the City of London (1751); Collection of the Yearly Bills of
Mortality from 1657 to 1758 (ed. by T. Birch, D.D. 1759);
Graunt’s Observations, Petty’s Another Essay and C. Morris’s
Observations are reprinted in this collection. Graunt and Petty’s
Essays are reprinted in Economic Writings of Sir W. Petty
(H. (1899).
B. W.*)

1 See map in London Statistics (vol. xix., 1909), an annual publication


of the London County Council, which besides these divisions shows
“Water London,” the London main drainage area, and the Central Criminal
Court district.
2 Charing Cross station was the scene of a remarkable catastrophe on
the 5th of December 1905, when a large part of the roof collapsed, and
the falling débris did very serious damage to the Avenue theatre, which
stands close to the station at a lower level.

3 The report appeared in eight volumes, the first of which, containing


the general conclusions to which allusion is here made, bore the number,
as a blue-book. Cd. 2597.

4 Over 200 local acts were repealed by schemes made under the act
of 1899.

5 A valuable article on “The Conqueror’s Footprints in Domesday” was


published in the English Historical Review in 1898 (vol. xiii. p. 17). This
article contains an account of Duke William’s movements after the battle
of Senlac between Enfield, Edmonton, Tottenham and Berkhampstead.

6 “A map of London engraved on copper-plate, dated 1497,” which


was bought by Ferdinand Columbus during his travels in Europe about
1518-1525, is entered in the catalogue of Ferdinand’s books, maps, &c.,
made by himself and preserved in the Cathedral Library at Seville, but
there is no clue to its existence.

7 One is in the Guildhall Library, and the other among the Pepysian
maps in Magdalene College, Cambridge.

8 This map of London by Norden is dated 1593, as stated above. The


same topographer published in his Middlesex a map of Westminster as
well as this one of the City of London.

9 Various changes in the names of the taverns are made in the folio
edition of this play (1616) from the quarto (1601); thus the Mermaid of
the quarto becomes the Windmill in the folio, and the Mitre of the quarto
is the Star of the folio.

10 The Great Revolt of 1381 (Oxford, 1906), p. 27.

11 In a valuable paper on “The Population of Old London” in


Blackwood’s Magazine for April 1891.
12 The old Bills of Mortality, although of value from being the only
authority on the subject, were never complete owing to various causes:
one being that large numbers of Roman Catholics and Dissenters were
not registered in the returns of the parish clerk who was a church officer.
The bills were killed by the action of the Registration Act for England and
Wales, which came into operation July 1, 1837. The weekly Returns of
the Registrar-General began in 1840.

13 “The invention of ‘bills of mortality’ is not so modern as has been


generally supposed, for their proper designation may be found in the
language of ancient Rome. Libitina was the goddess of funerals; her
officers were the Libitinarii our undertakers; her temple in which all
business connected with the last rites was transacted, in which the
account of deaths—ratio Libitinae—was kept, served the purpose of a
register office.”—Journal Statistical Society, xvii. 117 (1854).

14 The return was made “by special command from the Right
Honourable the Lords of His Majesty’s Privy Council.” The Privy Council
were at this time apprehensive of an approaching scarcity of food. The
numbers (130,268) were made up as follows: London Within the Walls
71,029, London Without the Walls 40,579, Old Borough of Southwark
(Bridge Without) 18,660.

15 R. R. Sharpe, London and the Kingdom (1894), i. 541.

LONDON CLAY, in geology, the most important member of


the Lower Eocene strata in the south of England. It is well developed
in the London basin, though not frequently exposed, partly because
it is to a great extent covered by more recent gravels and partly
because it is not often worked on a large scale. It is a stiff,
tenacious, bluish clay that becomes brown on weathering,
occasionally it becomes distinctly sandy, sometimes glauconitic,
especially towards the top; large calcareous septarian concretions
are common, and have been used in the manufacture of cement,
being dug for this purpose at Sheppey, near Southend, and at
Harwich, and dredged off the Hampshire coast. Nodular lumps of
pyrites and crystals of selenite are of frequent occurrence. The clay
has been employed for making bricks, tiles and coarse pottery, but it
is usually too tenacious for this purpose except in well-weathered or
sandy portions. The base of the clay is very regularly indicated by a
few inches of rounded flint pebbles with green and yellowish sand,
parts of this layer being frequently cemented by carbonate of lime.
The average thickness of the London Clay in the London basin is
about 450 ft.; at Windsor it is 400 ft. thick; beneath London it is
rather thicker, while in the south of Essex it is over 480 ft. In
Wiltshire it only reaches a few feet in thickness, while in Berkshire it
is some 50 or 60 ft. It is found in the Isle of Wight, where it is 300
ft. thick at Whitecliff Bay—here the beds are vertical and even
slightly reversed—and in Alum Bay it is 220 ft. thick. In Hampshire it
is sometimes known as the Bognor Beds, and certain layers of
calcareous sandstone within the clays are called Barnes or Bognor
Rock. In the eastern part of the London basin in east Kent the
pebbly basement bed becomes a thick deposit (60 ft.), forming part
of the Oldhaven and Blackheath Beds.

The London Clay is a marine deposit, and its fossils indicate a


moderately warm climate, the flora having a tropical aspect.
Among the fossils may be mentioned Panopoea intermedia,
Ditrupa plana, Teredina personata, Conus concinnus, Rostellaria
ampla, Nautilus centralis, Belosepia, foraminifera and diatoms.
Fish remains include Otodus obliquus, Sphyroenodus crassidens;
birds are represented by Halcyornis Toliapicus, Lithornis and
Odontopteryx, and reptiles by Chelone gigas, and other turtles,
Palaeophis, a serpent and crocodiles. Hyracotherium leporinum,
Palaeotherium and a few other mammals are recorded. Plant
remains in a pyritized condition are found in great abundance
and perfection on the shore of Sheppey; numerous species of
palms, screw pines, water lilies, cypresses, yews, leguminous
plants and many others occur; logs of coniferous wood bored
through by annelids and Teredo are common, and fossil resin
has been found at Highgate.

See Eocene; also W. Whitaker, “The Geology of London and


part of the Thames Valley,” Mem. Geol. Survey (1889), and
Sheet Memoirs of the Geol. Survey, London, Nos. 314, 315, 268,
329, 332, and Memoirs on the Geology of the Isle of Wight
(1889).

LONDONDERRY, EARLS AND MARQUESSES OF.


The 1st earl of Londonderry was Thomas Ridgeway (c. 1565-1631),
a Devon man, who was treasurer in Ireland from 1606 to 1616 and
was engaged in the plantation of Ulster. Ridgeway was made a
baronet in 1611, Baron Ridgeway in 1616 and earl of Londonderry in
1623. The Ridgeways held the earldom until March 1714, when
Robert, the 4th earl, died without sons. In 1726 Robert’s son-in-law,
Thomas Pitt (c. 1688-1729), son of Thomas Pitt, “Diamond Pitt,”
governor at Madras and uncle of the great earl of Chatham, was
created earl of Londonderry, the earldom again becoming extinct
when his younger son Ridgeway, the 3rd earl of this line, died
unmarried in January 1765. In 1796 Robert Stewart (1739-1821), of
Mount Stewart, Co. Down, was made earl of Londonderry in the Irish
peerage. He had been created Baron Londonderry in 1789 and
Viscount Castlereagh in 1795; in 1816 he was advanced to the rank
of marquess of Londonderry. The 3rd marquess married the heiress
of the Vane-Tempests and took the name of Vane instead of Stewart;
the 5th marquess called himself Vane-Tempest and the 6th marquess
Vane-Tempest-Stewart.

LONDONDERRY, CHARLES WILLIAM STEWART


(VANE), 3rd Marquess of (1778-1854), British soldier and
diplomatist, was the son of the 1st marquess by a second marriage
with the daughter of the 1st Earl Camden. He entered the army and
served in the Netherlands (1794), on the Rhine and Danube (1795),
in the Irish rebellion (1798), and Holland (1799), rising to be
colonel; and having been elected to parliament for Kerry he became
under secretary for war under his half-brother Castlereagh in 1807.
In 1808 he was given a cavalry command in the Peninsula, where he
brilliantly distinguished himself. In 1809, and again in the campaigns
of 1810, 1811, having become a major-general, he served under
Wellington in the Peninsula as his adjutant-general, and was at the
capture of Ciudad Rodrigo, but at the beginning of 1812 he was
invalided home. Castlereagh (see Londonderry, 2nd Marquess of)
then sent him to Berlin as minister, to represent Great Britain in the
allied British, Russian and Prussian armies; and as a cavalry leader
he played an important part in the subsequent fighting, while ably
seconding Castlereagh’s diplomacy. In 1814 he was made a peer as
Baron Stewart, and later in the year was appointed ambassador at
Vienna, and was a member of the important congresses which
followed. In 1822 his half-brother’s death made him 3rd marquess of
Londonderry, and shortly afterwards, disagreeing with Canning, he
resigned, being created Earl Vane (1823), and for some years lived
quietly in England, improving his Seaham estates. In 1835 he was
for a short time ambassador at St Petersburg. In 1852, after the
death of Wellington, when he was one of the pall-bearers, he
received the order of the Garter. He died on the 6th of March 1854.
He was twice married, first in 1808 to the daughter of the earl of
Darnley, and secondly in 1819 to the heiress of Sir Harry Vane-
Tempest (a descendant of Sir Piers Tempest, who served at
Agincourt, and heir to Sir Henry Vane, Bart.), when he assumed the
name of Vane. Frederick William Robert (1805-1872), his son by the
first marriage, became 4th marquess; and on the latter’s death in
1872, George Henry (1821-1884), the eldest son by the second
marriage, after succeeding as Earl Vane (according to the patent of
1823), became 5th marquess. In 1884 he was succeeded as 6th
marquess by his son Charles Stewart Vane-Tempest-Stewart (b.
1852), a prominent Conservative politician, who was viceroy of
Ireland (1886-1889), chairman of the London School Board (1895-
1897), postmaster-general (1900-1902), president of the Board of
Education (1902-1905) and lord president of the Council (1903-
1905).
LONDONDERRY, ROBERT STEWART, 2nd Marquess of
(1769-1822), British statesman, was the eldest son of Robert
Stewart of Ballylawn Castle, in Donegal, and Mount Stewart in Down,
an Ulster landowner, of kin to the Galloway Stewarts, who became
baron, viscount, earl and marquess in the peerage of Ireland. The
son, known in history as Lord Castlereagh, was born on the 18th of
June in the same year as Napoleon and Wellington. His mother was
Lady Sarah Seymour, daughter of the earl of Hertford. He went from
Armagh school to St John’s College, Cambridge, but left at the end
of his first year. With Lord Downshire, then holding sway over the
County Down, Lord Stewart had a standing feud, and he put forward
his son, in July 1790, for one of the seats. Young Stewart was
returned, but at a vast cost to his family, when he was barely
twenty-one. He took his seat in the Irish House of Commons at the
same time as his friend, Arthur Wellesley, M.P. for Trim, but sat later
for two close boroughs in England, still remaining member for Down
at College Green.

From 1796, when his father became an earl, he took the courtesy
title of Viscount Castlereagh, and becoming keeper of the privy seal
in Ireland, he acted as chief secretary, during the prolonged absence
of Mr Pelham, from February 1797. Castlereagh’s conviction was
that, in presence of threatened invasion and rebellion, Ireland could
only be made safe by union with Great Britain. In Lord Camden, as
afterwards in Lord Cornwallis, Castlereagh found a congenial chief;
though his favour with these statesmen was jealously viewed both
by the Irish oligarchy and by the English politicians who wished to
keep the machine of Irish administration in their own hands. Pitt
himself was doubtful of the expediency of making an Irishman chief
secretary, but his view was changed by the influence of Cornwallis.
In suppressing Lord Edward Fitzgerald’s conspiracy, and the rebellion
which followed in 1798, Castlereagh’s vigilance and firmness were
invaluable. His administration was denounced by a faction as harsh
and cruel—a charge afterwards repudiated by Grattan and Plunket—
but he was always on the side of lenity. The disloyal in Ireland, both
Jacobins and priest-led, the Protestant zealots and others who
feared the consequence of the Union, coalesced against him in
Dublin. Even there Castlereagh, though defeated in a first campaign
(1799), impressed Pitt with his ability and tact, with Cornwallis he
joined in holding out, during the second Union campaign (1800), the
prospect of emancipation to the Roman Catholics. They were aided
by free expenditure of money and promises of honours, methods too
familiar in Irish politics. When the Act of Union was carried through
the Irish parliament, in the summer of 1800, Castlereagh’s official
connexion with his native land practically ended. Before the Imperial
Parliament met he urged upon Pitt the measures which he and
Cornwallis thought requisite to make the Union effective. In spite of
his services and of Pitt’s support, disillusion awaited him. The king’s
reluctance to yield to the Roman Catholic claims was underestimated
by Pitt, while Cornwallis imprudently permitted himself to use
language which, though not amounting to a pledge, was construed
as one. George III. resented the arguments brought forward by
Castlereagh—“this young man” who had come over to talk him out
of his coronation oath. He peremptorily refused to sanction
emancipation, and Pitt and his cabinet made way for the Addington
administration. Thereupon Castlereagh resigned, with Cornwallis. He
took his seat at Westminster for Down, the constituency he had
represented for ten years in Dublin. The leadership of an Irish party
was offered to him, but he declined so to limit his political activity.
His father accepted, at Portland’s request, an Irish marquessate, on
the understanding that in the future he or his heirs might claim the
same rank in the Imperial Legislature; so that Castlereagh was able
to sit in the House of Commons as Marquess in 1821-1822.
Wilberforce discussed with Pitt the possibility of sending out
Castlereagh to India as governor-general, when the friction between
Lord Wellesley and the directors became grave; but Pitt objected, as
the plan would remove Castlereagh from the House of Commons,
which should be “the theatre of his future fame.”

In 1802, Castlereagh, at Pitt’s suggestion, became president of the


Board of Control in the Addington cabinet. He had, though not in
office, taken charge of Irish measures under Addington, including
the repression of the Rebellion Bill, and the temporary suspension of
the Habeas Corpus in 1801, and continued to advocate Catholic
relief, tithe reform, state payment of Catholic and dissenting clergy
and “the steady application of authority in support of the laws.” To
Lord Wellesley’s Indian policy he gave a staunch support, warmly
recognized by the governor-general. On Pitt’s return to office (May
1804), Castlereagh retained his post, and, next year, took over also
the duties of secretary for war and the colonies. Socially and
politically, the gifts of his wife, Lady Emily Hobart, daughter of a
former Irish viceroy, whom he had married in 1794, assisted him to
make his house a meeting-place of the party; and his influence in
parliament grew notwithstanding his defects of style, spoken and
written. As a manager of men he had no equal. After Pitt’s death his
surviving colleagues failed to form a cabinet strong enough to face
the formidable combination known as “All the Talents,” and
Castlereagh acquiesced in the resignation. But to the foreign policy
of the Fox-Greville ministry and its conduct of the war he was always
opposed. His objections to the Whig doctrine of withdrawal from
“Continental entanglements” and to the reduction of military
expenditure were justified when Fox himself was compelled “to nail
his country’s colours to the mast.”

The cabinet of “All the Talents,” weakened by the death of Fox and
the renewed quarrel with the king, went out in April 1807.
Castlereagh returned to the War Office under Portland, but grave
difficulties arose, though Canning at the Foreign Office was then
thoroughly at one with him. A priceless opportunity had been missed
after Eylau. The Whigs had crippled the transport service, and the
operations to avert the ruin of the coalition at Friedland came too
late. The Tsar Alexander believed that England would no longer
concern herself with the Continental struggle, and Friedland was
followed by Tilsit. The secret articles of that compact, denied at the
time by the Opposition and by French apologists, have now been
revealed from official records in M. Vandal’s work, Napoléon et
Alexandre. Castlereagh and Canning saw the vital importance of
nullifying the aim of this project. The seizure of the Danish squadron
at Copenhagen, and the measures taken to rescue the fleets of
Portugal and Sweden from Napoleon, crushed a combination as
menacing as that defeated at Trafalgar. The expedition to Portugal,
though Castlereagh’s influence was able only to secure Arthur
Wellesley a secondary part at first, soon dwarfed other issues. In the
debates on the Convention of Cintra, Castlereagh defended Wellesley
against parliamentary attacks: “A brother,” the latter wrote, “could
not have done more.” The depression produced by Moore’s
campaign in northern Spain, and the king’s repugnance to the
Peninsular operations, seemed to cut short Wellesley’s career; but
early in 1809, Castlereagh, with no little difficulty, secured his
friend’s appointment as commander-in-chief of the second
Portuguese expedition. The merit has been claimed for Canning by
Stapleton, but the evidence is all the other way.

Meanwhile, Castlereagh’s policy led to a crisis that clouded his own


fortunes. The breach between him and Canning was not due to his
incompetence in the conduct of the Walcheren expedition, In fact,
Castlereagh’s ejection was decided by Canning’s intrigues, though
concealed from the victim, months before the armament was sent
out to the Scheldt. In the selection of the earl of Chatham as
commander the king’s personal preference was known, but there is
evidence also that it was one of Canning’s schemes, as he reckoned,
if Chatham succeeded, on turning him into a convenient ministerial
figurehead. Canning was not openly opposed to the Walcheren
expedition, and on the Peninsular question he mainly differed from
Castlereagh and Wellington in fixing his hopes on national
enthusiasm and popular uprisings. Military opinion is generally
agreed that the plan of striking from Walcheren at Antwerp, the
French naval base, was sound. Napoleon heard the news with
dismay; in principle Wellington approved the plan. Castlereagh’s
proposal was for a coup de main, under strict conditions of celerity
and secrecy, as Antwerp was unable to make any adequate defence.
But Chatham, the naval authorities and the cabinet proceeded with a
deliberation explained by the fact that the war secretary had been
condemned in secret. The expedition, planned at the end of March,
did not reach Walcheren till the end of July 1809; and more time
was lost in movements against Batz and Flushing, protracted until an
unhealthy autumn prostrated the army, which was withdrawn,
discredited and disabled, in September. Public opinion threw the
whole blame upon Castlereagh, who then found that, in deference to
Canning, his colleagues had decreed his removal half a year earlier,
though they kept silence till the troops were brought back from
Walcheren. When Castlereagh learned from Percival that the slur
cast on him had its origin in a secret attack on him many months
before, he was cruelly hurt. The main charge against him was, he
says, that he would not throw over officers on whom unpopularity
fell, at the first shadow of ill-fortune. His refusal to rush into censure
of Moore, following Canning’s sudden change from eulogy to
denunciation, requires no defence. According to the ideas then
prevailing Castlereagh held himself justified in sending a challenge to
the original author, as he held, of a disloyal intrigue against a
colleague. In the subsequent duel Canning was wounded and the
rivals simultaneously resigned. In private letters to his father and
brother, Castlereagh urged that he was bound to show that he “was
not privy to his own disgrace.” When Canning published a lengthy
explanation of his conduct, many who had sided with him were
convinced that Castlereagh had been much wronged. The excuse
that the protest upon which the cabinet decided against Castlereagh
did not mention the minister’s name was regarded as a quibble. Men
widely differing in character and opinions—Walter Scott, Sidney
Smith, Brougham and Cobbett—took this view. Castlereagh loyally
supported the government in parliament, after Lord Wellesley’s
appointment to the Foreign Office. Though Wellington’s retreat after
Talavera had been included, with the disasters of the Corunna and
Walcheren campaigns, in the censures on Castlereagh, and though
ministers were often depressed and doubtful, Castlereagh never lost
faith in Wellington’s genius. Lord Wellesley’s resignation in 1812,
when the Whigs failed to come to terms with the regent, led to
Castlereagh’s return to office as foreign secretary (March 1812). The
assassination of Percival soon threw upon him the leadership of the
House of Commons, and this double burden he continued to bear
during the rest of his life.

From March 1812 to July 1822 Castlereagh’s biography is, in truth,


the history of England. Though never technically prime minister,
during these years he wielded a power such as few ministers have
exercised. Political opponents and personal ill-wishers admitted that
he was the ablest leader who ever controlled the House of Commons
for so long a period. As a diplomatist, nobody save Marlborough had
the same influence over men or was given equal freedom by his
colleagues at home. Foreigners saw in him the living presence of
England in the camp of the Allies. At the War Office he had been
hampered by the lack of technical knowledge, while nature had not
granted him, as an organizer, the powers of a Carnot or Roon. But in
diplomacy his peculiar combination of strength and charm, of
patience and conciliatory adroitness, was acknowledged by all. At
the Foreign Office he set himself at once to meet Napoleon’s designs
in northern Europe, where Russia was preparing for her life-and-
death struggle. Lord Wellesley paid a high tribute to Castlereagh’s
conduct in this situation, and Wellington declared that he had then
“rendered to the world the most important service that ever fell to
the lot of any individual to perform.” Castlereagh wisely rejected
Napoleon’s insincere overtures for peace. After the Moscow débâcle
Napoleon’s fate was affected not only by Wellington’s progress in
Spain, but by the attitude of the northern powers and by the action
of Turkey, due to Castlereagh’s opportune disclosure to the Porte of
the scheme of partition at Tilsit. At home, the repeal of the Orders in
Council was carried, the damage to British trade plainly outweighing
the injury inflicted on France by the restrictive system. The British
subsidies to the Allies were largely increased as the operations of
1813 developed, but all Castlereagh’s skill was needed to keep the
Coalition together. The Allied powers were willing, even after Leipzig,
to treat with France on the basis of restoring her “natural
frontiers”—the Rhine, the Alps and the Pyrenees; but Castlereagh
protested. He would not allow the enemy to take ground for another
tiger-spring. Before the Conference of Châtillon, where Napoleon
sent Caulaincourt to negotiate for peace—with the message
scribbled on the margin of his instructions, “Ne signez rien”—
Aberdeen wrote to hasten Castlereagh’s coming: “Everything which
has been so long smothered is now bursting forth”; and again, “Your
presence has done much and would, I have no doubt, continue to
sustain them (the Allies) in misfortune.” The Liverpool cabinet then
and later were as urgent in pressing him to return to lead the House
of Commons. He had lost his seat for Down in 1805, and afterwards
sat for British boroughs; but in 1812 he was re-elected by his old
constituents; and again in 1818 and 1820, sitting, after he became
marquess of Londonderry in 1821, for Orford. Early in 1814 his
colleagues reluctantly consented to his visit to the allied
headquarters. The Great Alliance showed signs of weakness and
division. Austria was holding back; Prussia had almost broken away;
above all, the ambiguous conduct of Alexander bred alarm and
doubt. This situation became increasingly serious while Napoleon
was giving daily proofs that his military genius, confronting a
hesitant and divided enemy, was at its best. Castlereagh strove to
keep the Allies together, to give no excuse for those separate
arrangements upon which Napoleon was reckoning, to assert no
selfish policy for England, to be tied by no theoretical consistency. At
the Châtillon conferences England was represented by others, but
Castlereagh was present with supreme authority over all, and it was
he who determined the result. He declined to commit his country
either to a blank refusal to negotiate with Napoleon or to the
advocacy of a Bourbon restoration. He was ready to give up almost
the whole of England’s conquests, but he insisted on the return of
France within her ancient limits as the basis of a settlement.
Caulaincourt’s advice was to take advantage of these overtures; but
his master was not to be advised. The counter-projects that he
urged Caulaincourt to submit to were advanced after his victory at
Montereau, when he boasted that he was nearer to Munich than the
Allies were to Paris. Even before the Châtillon conference was
dissolved (March 18th), Castlereagh saw that Caulaincourt’s efforts
would never bend Napoleon’s will. The Allies adopted his view and
signed the treaty of Chaumont (March 1st), “my treaty,” as
Castlereagh called it, with an unusual touch of personal pride;
adding “Upon the face of the treaty this year our engagement is
equivalent to theirs united.” The power of England when she threw
her purse into the scale had been just exhibited at Bar-sur-Aube,
when at a council of all the representatives of the powers the retreat
of the allied armies was discussed. Bernadotte, playing a waiting
game in Holland, was unwilling to reinforce Blücher, then in a
dangerous position, by the Russian and Prussian divisions of
Winzingerode and Bülow, temporarily placed under his orders.
Having asked for and received the assurance that the military
leaders were agreed in holding the transfer necessary, Castlereagh
declared that he took upon himself the responsibility of bringing the
Swedish prince to reason. The withholding of the British subsidies
was a vital matter, not only with Bernadotte but with all the powers.
Castlereagh’s avowed intention to take this step without waiting for
sanction from his cabinet put an end to evasion and delay. Blücher
was reinforced by the two divisions; the battle of Laon was fought
and won, and the allies occupied the French capital. In April 1814
Castlereagh arrived in Paris. He did not disguise his discontent with
Napoleon’s position at Elba, close to the French coast, though he
advised England not to separate herself at this crisis from her allies.
His uneasiness led him to summon Wellington from the south to the
Embassy in Paris. He hastened himself to London during the visit of
the allied sovereigns, and met with a splendid reception. He was
honoured with the Garter, being one of the few commoners ever
admitted to that order. When the House of Commons offered to the
Crown its congratulations upon the treaty of peace, Castlereagh’s
triumph was signalized by a brilliantly eloquent panegyric from
Canning, and by a recantation of his former doubts and
denunciations from Whitbread. His own dignified language
vindicated his country from the charge of selfish ambition.

His appointment as British representative at Vienna, where the


congress was to meet in September, was foreseen; but meanwhile
he was not idle. The war with the United States, originating in the
non-intercourse dispute and the Orders in Council, did not cease
with the repeal of the latter. It lasted through 1814 till the signing of
the treaty of Ghent, soon before the flight from Elba. In parliament
the ministry, during Castlereagh’s absence, had been poorly
championed. Canning had thrown away his chance by his unwise
refusal of the Foreign Office. None of the ministers had any
pretension to lead when Castlereagh was busy abroad and Canning
was sulking at home, and Castlereagh’s letters to Vansittart, the
chancellor of the exchequer, show how these difficulties weighed
upon him in facing the position at Vienna, where it was imperative
for him to appear. At Vienna he realized at once that the ambition of
Russia might be as formidable to Europe and to Great Britain as that
of the fallen tyrant. His aim throughout had been to rescue Europe
from military domination; and when he found that Russia and
Prussia were pursuing ends incompatible with the general interest,
he did not hesitate to take a new line. He brought about the secret
treaty (Jan. 3, 1815) between Great Britain, Austria and France,
directed against the plans of Russia in Poland and of Prussia in
Saxony. Through Castlereagh’s efforts, the Polish and Saxon
questions were settled on the basis of compromise. The threat of
Russian interference in the Low Countries was dropped.

While the Congress was still unfinished, Napoleon’s escape from


Elba came like a thunderclap. Castlereagh had come home for a
short visit (Feb. 1815), at the urgent request of the cabinet, just
before the flight was known. The shock revived the Great Alliance
under the compact of Chaumont. All energies were directed to
preparing for the campaign of Waterloo. Castlereagh’s words in
parliament were, “Whatever measures you adopt or decision you
arrive at must rest on your own power and not on reliance on this
man.” Napoleon promptly published the secret treaty which
Castlereagh had concluded with Metternich and Talleyrand, and the
last left in the French archives. But Russia and Prussia, though much
displeased, saw that, in the face of Bonaparte’s return, they dared
not weaken the Alliance. British subsidies were again poured out like
water. After Napoleon’s overthrow, Castlereagh successfully urged
his removal to St Helena, where his custodians were charged to treat
him “with all the respect due to his rank, but under such precautions
as should render his escape a matter of impossibility.” Some of the
continental powers demanded, after Waterloo, fines and cessions
that would have crushed France; but in November a peace was
finally concluded, mainly by Castlereagh’s endeavours, minimising
the penalties exacted, and abandoning on England’s part the whole
of her share of the indemnity. The war created an economic situation
at home which strengthened the Whigs and Radicals, previously
discredited by their hostility to a patriotic struggle. In 1816 the
Income Tax was remitted, despite Castlereagh’s contention that
something should first be done to reduce the Debt Charge. His
policy, impressed upon British representatives abroad, was “to turn
the confidence Great Britain inspired to the account of peace, by
exercising a conciliatory influence in Europe.” Brougham’s action, at
the end of 1815, denouncing the Holy Alliance, even in its early
form, was calculated to embarrass England, though she was no
party to what Castlereagh described as a “piece of sublime
mysticism and nonsense.”

While he saw no reason in this for breaking up the Grand Alliance,


which he looked upon as a convenient organ of diplomatic
intercourse and as essential for the maintenance of peace, he
regarded with alarm “the little spirit of German intrigue,” and agreed
with Wellington that to attempt to crush France, as the Prussians
desired, or to keep her in a perpetual condition of tutelage under a
European concert from which she herself should be excluded, would
be to invite the very disaster which it was the object of the Alliance
to avoid. It was not till Metternich’s idea of extending the scope of
the Alliance, by using it to crush “the revolution” wherever it should
raise its head, began to take shape, from the conference of Aix-la-
Chapelle (1818) onward, that Great Britain’s separation from her
continental allies became inevitable. Against this policy of the
reactionary powers Castlereagh from the first vigorously protested.
As little was he prepared to accept the visionary schemes of the
emperor Alexander for founding an effective “confederation of
Europe” upon the inclusive basis of the Holy Alliance (see Alexander
I. of Russia).
Meanwhile financial troubles at home, complicated by the
resumption of cash payments in 1819, led to acute social tension.
“Peterloo” and the “Six Acts” were furiously denounced, though the
bills introduced by Sidmouth and Castlereagh were carried in both
Houses by overwhelming majorities. The danger that justified them
was proved beyond contest by the Cato Street Conspiracy in 1820. It
is now admitted by Liberal writers that the “Six Acts,” in the
circumstances, were reasonable and necessary. Throughout,
Castlereagh maintained his tranquil ascendancy in the House of
Commons, though he had few colleagues who were capable of
standing up against Brougham. Canning, indeed, had returned to
office and had defended the “Six Acts,” but Castlereagh bore the
whole burden of parliamentary leadership, as well as the enormous
responsibilities of the Foreign Office. His appetite for work caused
him to engage in debates and enquiries on financial and legal
questions when he might have delegated the task to others. Althorp
was struck with his unsleeping energy on the Agricultural Distress
Committee; “His exertions, coupled with his other duties—and
unfortunately he was always obstinate in refusing assistance—
strained his constitution fearfully, as was shown by his careworn
brow and increasing paleness.” In 1821, on Sidmouth’s retirement,
he took upon himself the laborious functions of the Home Office.
The diplomatic situation had become serious. The policy of
“intervention,” with which Great Britain had consistently refused to
identify herself, had been proclaimed to the world by the famous
Troppau Protocol, signed by Russia, Austria and Prussia (see Troppau,
Congress of). The immediate occasion was the revolution at Naples,
where the egregious Spanish constitution of 1812 had been forced
on the king by a military rising. With military revolts, as with paper
constitutions of an unworkable type, Castlereagh had no sympathy;
and in this particular case the revolution, in his opinion, was wholly
without excuse or palliation. He was prepared to allow the
intervention of Austria, if she considered her rights under the treaty
of 1813 violated, or her position as an Italian Power imperilled. But
he protested against the general claim, embodied in the Protocol, of
the European powers to interfere, uninvited, in the internal concerns
of sovereign states; he refused to make Great Britain, even tacitly, a
party to such interference, and again insisted that her part in the
Alliance was defined by the letter of the treaties, beyond which she
was not prepared to go. In no case, he affirmed, would Great Britain
“undertake the moral responsibility for administering a general
European police,” which she would never tolerate as applied to
herself.

To Troppau, accordingly, no British plenipotentiary was sent, since


the outcome of the conferences was a foregone conclusion; though
Lord Stewart came from Vienna to watch the course of events. At
Laibach an attempt to revive the Troppau proposals was defeated by
the firm opposition of Stewart; but a renewal of the struggle at
Verona in the autumn of 1822 was certain. Castlereagh, now
marquess of Londonderry, was again to be the British representative,
and he drew up for himself instructions that were handed over
unaltered by Canning, his successor at the Foreign Office, to the new
plenipotentiary, Wellington. In the threatened intervention of the
continental powers in Spain, as in their earlier action towards Naples
and Sardinia, England refused to take part. The Spanish
revolutionary movement, Castlereagh wrote, “was a matter with
which, in the opinion of the English cabinet, no foreign power had
the smallest right to interfere.” Before, however, the question of
intervention in Spain had reached its most critical stage the
development of the Greek insurrection against the Ottoman
government brought up the Eastern Question in an acute form,
which profoundly modified the relations of the powers within the
Alliance, and again drew Metternich and Castlereagh together in
common dread of an isolated attack by Russia upon Turkey. A visit of
King George IV. to Hanover, in October 1821, was made the occasion
of a meeting between Lord Londonderry and the Austrian chancellor.
A meeting so liable to misinterpretation was in Castlereagh’s opinion
justified by the urgency of the crisis in the East, “a practical
consideration of the greatest moment,” which had nothing in
common with the objectionable “theoretical” question with which the
British government had refused to concern itself. Yet Castlereagh, on
this occasion, showed that he could use the theories of others for his
own practical ends; and he joined cordially with Metternich in taking
advantage of the emperor Alexander’s devotion to the principles of
the Alliance to prevent his taking an independent line in the Eastern
Question. It was, indeed, the belief that this question would be
made the matter of common discussion at the congress that led
Castlereagh to agree to be present at Verona; and in his Instructions
he foreshadowed the policy afterwards carried out by Canning,
pointing out that the development of the war had made the
recognition of the belligerent rights of the Greeks inevitable, and
quoting the precedent of the Spanish American colonies as exactly
applicable. With regard to the Spanish colonies, moreover, though he
was not as yet prepared to recognize their independence de jure, he
was strongly of opinion that the Spanish government should do so
since “other states would acknowledge them sooner or later, and it is
to the interest of Spain herself to find the means of restoring an
intercourse when she cannot succeed in restoring a dominion.”

But the tragic ending of Castlereagh’s strenuous life was near; and
the credit of carrying out the policy foreshadowed in the Instructions
was to fall to his rival Canning. Lord Londonderry’s exhaustion
became evident during the toilsome session of 1822. Both the king
and Wellington were struck by his overwrought condition, which his
family attributed to an attack of the gout and the lowering remedies
employed. Wellington warned Dr Bankhead that Castlereagh was
unwell, and, perhaps, mentally disordered. Bankhead went down to
North Cray and took due precautions. Castlereagh’s razors were
taken away, but a penknife was forgotten in a drawer, and with this
he cut his throat (August 12, 1822). He had just before said, “My
mind, my mind, is, as it were, gone”; and, when he saw his wife and
Bankhead talking together, he moaned “there is a conspiracy laid
against me.” It was as clear a case of brain disease as any on
record. But this did not prevent his enemies of the baser sort from
asserting, without a shadow of proof, that the suicide was caused by
terror at some hideous and undefined charge. The testimony of
statesmen of the highest character and of all parties to Castlereagh’s
gifts and charm is in strong contrast with the flood of vituperation
and calumny poured out upon his memory by those who knew him
not.

Bibliography.—Castlereagh’s correspondence and papers were


published by his brother and successor (1850-1853) in twelve
volumes. Sir Archibald Alison’s Biography in three volumes came
out in 1861, with copious extracts from the manuscripts
preserved at Wynyard. It was made the subject of an interesting
essay in the Quarterly Review for January 1862, reprinted in
Essays by the late Marquis of Salisbury (London, 1905). A
graceful sketch by Theresa, Marchioness of Londonderry
(London, 1904), originally brought out in the Anglo-Saxon
Review, contains some extracts from Castlereagh’s unpublished
correspondence with his wife, the record of an enduring and
passionate attachment which throws a new light on the
(E. man.
D. J. W.)

LONDONDERRY, a northern county of Ireland in the


province of Ulster, bounded N. by the Atlantic, W. by Lough Foyle
and Donegal, E. by Antrim and Lough Neagh, and S. by Tyrone. The
area is 522,315 acres, or about 816 sq. m. The county consists
chiefly of river valleys surrounded by elevated table-lands rising
occasionally into mountains, while on the borders of the sea-coast
the surface is generally level. The principal river is the Roe, which
flows northward from the borders of Tyrone into Lough Foyle below
Newton-Limavady, and divides the county into two unequal parts.
Farther west the Faughan also falls into Lough Foyle, and the river
Foyle passes through a small portion of the county near its north-
western boundary. In the south-east the Moyola falls into Lough
Neagh, and the Lower Bann from Lough Neagh forms for some
distance its eastern boundary with Antrim. The only lake in the
county is Lough Finn on the borders of Tyrone, but Lough Neagh
forms about 6 m. of its south-eastern boundary. The scenery of the
shores of Lough Foyle and the neighbouring coast is attractive, and
Castlerock, Downhill, Magilligan and Portstewart are favourite
seaside resorts. On the flat Magilligan peninsula, which forms the
eastern horn of Lough Foyle, the base-line of the trigonometrical
survey of Ireland was measured in 1826. The scenery of the Roe
valley, with the picturesque towns of Limavady and Dungiven, is also
attractive, and the roads from the latter place to Draperstown and to
Maghera, traversing the passes of Evishgore and Glenshane
respectively, afford fine views of the Sperrin and Slieve Gallion
mountains.

The west of this county consists of Dalradian mica-schist, with


some quartzite, and is a continuation of the northern region of
Tyrone. An inlier of these rocks appears in the rising ground east
of Dungiven, including dark grey crystalline limestone. Old Red
Sandstone and Lower Carboniferous Sandstone overlie these old
rocks in the south and east, meeting the igneous “green rocks”
of Tyrone, and the granite intrusive in them, at the north end of
Slieve Gallion. Triassic sandstone covers the lower slope of Slieve
Gallion on the south-east towards Moneymore, and rises above
the Carboniferous Sandstone from Dungiven northward. At
Moneymore we reach the western scarp of the white Limestone
(Chalk) and the overlying basalt of the great plateaus, which dip
down eastward under Lough Neagh. The basalt scarp, protecting
chalk and patches of Liassic and Rhaetic strata, rises to 1260 ft.
in Benevenagh north of Limavady, and repeats the finest
features of the Antrim coast. A raised shelf with post-glacial
marine clays forms the flat land west of Limavady. Haematite
has been mined on the south flank of Slieve Gallion.

The excessive rainfall and the cold and uncertain climate are
unfavourable for agriculture. Along the sea-coast there is a
district of red clay formed by the decomposition of sandstone,
and near the mouth of the Roe there is a tract of marl. Along the
valleys the soil is often fertile, and the elevated districts of the
clay-slate region afford pasture for sheep. The acreage of
pasture-land does not greatly exceed that of tillage. Oats,
potatoes and turnips are chiefly grown, with some flax; and
cattle, sheep, pigs and poultry are kept in considerable numbers.
The staple manufacture of the county is linen. The manufacture
of coarse earthenware is also carried on, and there are large
distilleries and breweries and some salt-works. There are
fisheries for salmon and eels on the Bann, for which Coleraine is
the headquarters. The deep-sea and coast fisheries are valuable,
and are centred at Moville in Co. Donegal. The city of
Londonderry is an important railway centre. The Northern
Counties (Midland) main line reaches it by way of Coleraine and
the north coast of the county, and the same railway serves the
eastern part of the county, with branches from Antrim to
Magherafelt, and Magherafelt to Cookstown (Co. Tyrone), to
Draperstown and to Coleraine, and from Limavady to Dungiven.
The Great Northern railway reaches Londonderry from the
south, and the city is also the starting-point of the County
Donegal, and the Londonderry and Lough Swilly railways.

The population decreases (152,009 in 1891; 144,404 in 1901)


and emigration is extensive, though both decrease and
emigration are well below the average of the Irish counties. Of
the total, about 43% are Roman Catholics, and nearly 50%
Presbyterians or Protestant Episcopalians. Londonderry (pop.
38,892), Coleraine (6958) and Limavady (2692) are the principal
towns, while Magherafelt and Moneymore are lesser market
towns. The county comprises six baronies. Assizes are held at
Londonderry, and quarter sessions at Coleraine, Londonderry
and Magherafelt. The county is represented in parliament by two
members, for the north and south divisions respectively. The
Protestant and Roman Catholic dioceses of Armagh, Derry and
Down each include parts of the county.

At an early period the county was inhabited by the O’Cathans or


O’Catrans, who were tributary to the O’Neills. Towards the close of
the reign of Elizabeth the county was seized, with the purpose of
checking the power of the O’Neills, when it received the name of
Coleraine, having that town for its capital. In 1609, after the
confiscation of the estates of the O’Neills, the citizens of London
obtained possession of the towns of Londonderry and Coleraine and
adjoining lands, 60 acres out of every 1000 being assigned for
church lands. The common council of London undertook to expend
£20,000 on the reclamation of the property, and elected a body of
twenty-six for its management, who in 1613 were incorporated as
the Irish Society, and retained possession of the towns of
Londonderry and Coleraine, the remainder of the property being
divided among twelve of the great livery companies. Their estates
were sequestrated by James I., and in 1637 the charter of the Irish
Society was cancelled. Cromwell restored the society to its former
position, and Charles II. at the Restoration granted it a new charter,
and confirmed the companies in their estates. In the insurrection of
1641 Moneymore was seized by the Irish, and Magherafelt and
Bellaghy, then called Vintner’s Town, burned, as well as other towns
and villages. There are several stone circles, and a large number of
artificial caves. The most ancient castle of Irish origin is that of
Carrickreagh; and of the castles erected by the English those of
Dungiven and Muff are in good preservation. The abbey of
Dungiven, founded in 1109, and standing on a rock about 200 ft.
above the river Roe, is a picturesque ruin.
LONDONDERRY, or Derry, a city, county of a city,
parliamentary borough (returning one member) and the chief town
of Co. Londonderry, Ireland, 4 m. from the junction of the river Foyle
with Lough Foyle, and 95 m. N.N.W. of Belfast. Pop. (1901) 38,892.
The city is situated on an eminence rising abruptly from the west
side of the river to a height of about 120 ft. The eminence is
surrounded by hills which reach, a few miles to the north, an
elevation of upwards of 1500 ft., and the river and lough complete
an admirable picture. The city is surrounded by an ancient rampart
about a mile in circumference, having seven gates and several
bastions, but buildings now extend beyond this boundary. The
summit of the hill, at the centre of the town, is occupied by a
quadrangular area from which the main streets diverge. Some old
houses with high pyramidal gables remain but are much modernized.
The Protestant cathedral of St Columba, in Perpendicular style, was
completed from the design of Sir John Vanbrugh in 1633, at a cost
of £4000 contributed by the city of London, and was enlarged and
restored in 1887. The spire was added in 1778 and rebuilt in 1802.
The bishop’s palace, erected in 1716, occupies the site of the abbey
founded by Columba. The abbot of this monastery, on being made
bishop, erected in 1164 Temple More or the “Great Church,” one of
the finest buildings in Ireland previous to the Anglo-Norman
invasion. The original abbey church was called the “Black Church,”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like