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

Instant Download Foundations of PyGTK Development: GUI Creation With Python W. David Ashley PDF All Chapters

PyGTK

Uploaded by

hitaciasick
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
64 views

Instant Download Foundations of PyGTK Development: GUI Creation With Python W. David Ashley PDF All Chapters

PyGTK

Uploaded by

hitaciasick
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Download the full version of the textbook now at textbookfull.

com

Foundations of PyGTK Development: GUI


Creation with Python W. David Ashley

https://textbookfull.com/product/foundations-of-
pygtk-development-gui-creation-with-python-w-
david-ashley/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Foundations for Analytics with Python 1st Edition Clinton


W. Brownley

https://textbookfull.com/product/foundations-for-analytics-with-
python-1st-edition-clinton-w-brownley/

textbookfull.com

Foundation Dynamic Web Pages with Python: Create Dynamic


Web Pages with Django and Flask David Ashley

https://textbookfull.com/product/foundation-dynamic-web-pages-with-
python-create-dynamic-web-pages-with-django-and-flask-david-ashley/

textbookfull.com

Create GUI Applications with Python Qt5 PySide2 Edition


Martin Fitzpatrick

https://textbookfull.com/product/create-gui-applications-with-python-
qt5-pyside2-edition-martin-fitzpatrick/

textbookfull.com

Copyright's Highway: From the Printing Press to the Cloud,


Second Edition Paul Goldstein

https://textbookfull.com/product/copyrights-highway-from-the-printing-
press-to-the-cloud-second-edition-paul-goldstein/

textbookfull.com
Storey s Guide to Raising Rabbits Fifth Edition. Edition
Bob Bennett

https://textbookfull.com/product/storey-s-guide-to-raising-rabbits-
fifth-edition-edition-bob-bennett/

textbookfull.com

Muller’s Imaging of the Chest 2nd Edition Christopher


Walker

https://textbookfull.com/product/mullers-imaging-of-the-chest-2nd-
edition-christopher-walker/

textbookfull.com

Daoism in Early China: Huang-Lao Thought in Light of


Excavated Texts Feng Cao

https://textbookfull.com/product/daoism-in-early-china-huang-lao-
thought-in-light-of-excavated-texts-feng-cao/

textbookfull.com

The New Couple in 5B A Novel Unger Lisa

https://textbookfull.com/product/the-new-couple-in-5b-a-novel-unger-
lisa/

textbookfull.com

International Flows in the Belt and Road Initiative


Context: Business, People, History and Geography Hing Kai
Chan
https://textbookfull.com/product/international-flows-in-the-belt-and-
road-initiative-context-business-people-history-and-geography-hing-
kai-chan/
textbookfull.com
Induction Machines Handbook: Transients, Control
Principles, Design and Testing 3rd Edition Ion Boldea

https://textbookfull.com/product/induction-machines-handbook-
transients-control-principles-design-and-testing-3rd-edition-ion-
boldea/
textbookfull.com
Foundations
of PyGTK
Development
GUI Creation with Python

Second Edition

W. David Ashley
Andrew Krause
Foundations of PyGTK
Development
GUI Creation with Python
Second Edition

W. David Ashley
Andrew Krause
Foundations of PyGTK Development: GUI Creation with Python
W. David Ashley Andrew Krause
AUSTIN, TX, USA Leesburg, VA, USA

ISBN-13 (pbk): 978-1-4842-4178-3 ISBN-13 (electronic): 978-1-4842-4179-0


https://doi.org/10.1007/978-1-4842-4179-0
Library of Congress Control Number: 2018966864

Copyright © 2019 by W. David Ashley and Andrew Krause


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Celestin Suresh John
Development Editor: James Markham
Coordinating Editor: Divya Modi
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-4178-3. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
I dedicate this book to my wife.
Without you, all of this would not be possible.
—W. David Ashley
Table of Contents
About the Author�����������������������������������������������������������������������������������������������������xv

About the Technical Reviewers�����������������������������������������������������������������������������xvii


Acknowledgments��������������������������������������������������������������������������������������������������xix

Introduction������������������������������������������������������������������������������������������������������������xxi

Chapter 1: Getting Started���������������������������������������������������������������������������������������� 1


Differences Between GTK+ 2.x and 3.x���������������������������������������������������������������������������������������� 1
Installing GTK+ 3.x������������������������������������������������������������������������������������������������������������������������ 3
Summary�������������������������������������������������������������������������������������������������������������������������������������� 4

Chapter 2: The Application and ApplicationWindow Classes����������������������������������� 5


The Gtk.Application Class������������������������������������������������������������������������������������������������������������� 5
Primary vs. Local Instance������������������������������������������������������������������������������������������������������������ 7
Actions������������������������������������������������������������������������������������������������������������������������������������������ 7
Dealing with the Command Line��������������������������������������������������������������������������������������������������� 8
Example���������������������������������������������������������������������������������������������������������������������������������������� 9
The Gtk.ApplicationWindow Class����������������������������������������������������������������������������������������������� 10
Actions���������������������������������������������������������������������������������������������������������������������������������������� 10
Locking��������������������������������������������������������������������������������������������������������������������������������������� 11
Example�������������������������������������������������������������������������������������������������������������������������������������� 11
Summary������������������������������������������������������������������������������������������������������������������������������������ 16

Chapter 3: Some Simple GTK+ Applications����������������������������������������������������������� 17


Hello World���������������������������������������������������������������������������������������������������������������������������������� 17
GTK+ Widget Hierarchy��������������������������������������������������������������������������������������������������������������� 20

v
Table of Contents

Extending HelloWorld.py������������������������������������������������������������������������������������������������������������� 20
The GTK.Label Widget������������������������������������������������������������������������������������������������������������ 22
Layout Containers������������������������������������������������������������������������������������������������������������������ 23
Signals and Callbacks����������������������������������������������������������������������������������������������������������������� 24
Connecting the Signal����������������������������������������������������������������������������������������������������������� 24
Callback Methods/Functions������������������������������������������������������������������������������������������������� 26
Events����������������������������������������������������������������������������������������������������������������������������������������� 26
Event Types���������������������������������������������������������������������������������������������������������������������������� 28
Using Specific Event Structures�������������������������������������������������������������������������������������������� 28
Further GTK+ Methods���������������������������������������������������������������������������������������������������������������� 29
Gtk.Widget Methods�������������������������������������������������������������������������������������������������������������� 30
Gtk.Window Methods������������������������������������������������������������������������������������������������������������ 31
Process Pending Events�������������������������������������������������������������������������������������������������������� 33
Buttons���������������������������������������������������������������������������������������������������������������������������������������� 33
Test Your Understanding������������������������������������������������������������������������������������������������������������� 36
Exercise 1: Using Events and Properties������������������������������������������������������������������������������� 36
Summary������������������������������������������������������������������������������������������������������������������������������������ 37

Chapter 4: Containers��������������������������������������������������������������������������������������������� 39
GTK.Container����������������������������������������������������������������������������������������������������������������������������� 39
Decorator Containers������������������������������������������������������������������������������������������������������������� 40
Layout Containers������������������������������������������������������������������������������������������������������������������ 40
Resizing Children������������������������������������������������������������������������������������������������������������������� 41
Container Signals������������������������������������������������������������������������������������������������������������������ 42
Horizontal and Vertical Boxes����������������������������������������������������������������������������������������������������� 42
Horizontal and Vertical Panes����������������������������������������������������������������������������������������������������� 48
Grids�������������������������������������������������������������������������������������������������������������������������������������������� 52
Grid Spacing�������������������������������������������������������������������������������������������������������������������������� 54
Fixed Containers������������������������������������������������������������������������������������������������������������������������� 54
Expanders����������������������������������������������������������������������������������������������������������������������������������� 57

vi
Table of Contents

Notebook������������������������������������������������������������������������������������������������������������������������������������� 60
Notebook Properties�������������������������������������������������������������������������������������������������������������� 62
Tab Operations����������������������������������������������������������������������������������������������������������������������� 63
Event Boxes�������������������������������������������������������������������������������������������������������������������������������� 64
Test Your Understanding������������������������������������������������������������������������������������������������������������� 69
Exercise 1: Using Multiple Containers����������������������������������������������������������������������������������� 69
Exercise 2: Even More Containers����������������������������������������������������������������������������������������� 70
Summary������������������������������������������������������������������������������������������������������������������������������������ 70

Chapter 5: Basic Widgets��������������������������������������������������������������������������������������� 71


Using Push Buttons��������������������������������������������������������������������������������������������������������������������� 71
Toggle Buttons���������������������������������������������������������������������������������������������������������������������������� 74
Check Buttons����������������������������������������������������������������������������������������������������������������������� 76
Radio Buttons������������������������������������������������������������������������������������������������������������������������ 79
Text Entries��������������������������������������������������������������������������������������������������������������������������������� 82
Entry Properties��������������������������������������������������������������������������������������������������������������������� 84
Inserting Text into a Gtk.Entry Widget������������������������������������������������������������������������������������ 85
Spin Buttons�������������������������������������������������������������������������������������������������������������������������������� 85
Adjustments�������������������������������������������������������������������������������������������������������������������������� 85
A Spin Button Example���������������������������������������������������������������������������������������������������������� 86
Horizontal and Vertical Scales���������������������������������������������������������������������������������������������������� 89
Additional Buttons����������������������������������������������������������������������������������������������������������������������� 92
Color Button��������������������������������������������������������������������������������������������������������������������������� 92
File Chooser Buttons������������������������������������������������������������������������������������������������������������� 95
Font Buttons������������������������������������������������������������������������������������������������������������������������ 100
Test Your Understanding����������������������������������������������������������������������������������������������������������� 103
Exercise 1: Renaming Files������������������������������������������������������������������������������������������������� 103
Exercise 2: Spin Buttons and Scales����������������������������������������������������������������������������������� 104
Summary���������������������������������������������������������������������������������������������������������������������������������� 104

vii
Table of Contents

Chapter 6: Dialogs������������������������������������������������������������������������������������������������ 107


Creating Your Own Dialogs�������������������������������������������������������������������������������������������������������� 108
Creating a Message Dialog�������������������������������������������������������������������������������������������������� 109
Nonmodal Message Dialog�������������������������������������������������������������������������������������������������� 115
Another Dialog Example������������������������������������������������������������������������������������������������������ 117
Built-in Dialogs������������������������������������������������������������������������������������������������������������������������� 121
Message Dialogs����������������������������������������������������������������������������������������������������������������� 121
About Dialogs���������������������������������������������������������������������������������������������������������������������� 124
Gtk.FileChooser Dialogs������������������������������������������������������������������������������������������������������� 130
Color Selection Dialogs�������������������������������������������������������������������������������������������������������� 139
Font Selection Dialogs��������������������������������������������������������������������������������������������������������� 143
Dialogs with Multiple Pages������������������������������������������������������������������������������������������������������ 146
Creating Gtk.Assistant Pages���������������������������������������������������������������������������������������������� 151
Gtk.ProgressBar������������������������������������������������������������������������������������������������������������������ 154
Page Forward Methods������������������������������������������������������������������������������������������������������� 155
Test Your Understanding����������������������������������������������������������������������������������������������������������� 156
Exercise 1: Implementing File Chooser Dialogs������������������������������������������������������������������� 157
Summary���������������������������������������������������������������������������������������������������������������������������������� 157

Chapter 7: Python and GTK+��������������������������������������������������������������������������������� 159


Arguments and Keyword Arguments���������������������������������������������������������������������������������������� 159
Logging������������������������������������������������������������������������������������������������������������������������������������� 162
When to Use Logging����������������������������������������������������������������������������������������������������������� 162
Some Simple Examples������������������������������������������������������������������������������������������������������� 163
Logging to a File������������������������������������������������������������������������������������������������������������������ 164
Logging from Multiple Modules������������������������������������������������������������������������������������������� 165
Logging Variable Data���������������������������������������������������������������������������������������������������������� 166
Changing the Format of Displayed Messages��������������������������������������������������������������������� 166

viii
Table of Contents

Exceptions��������������������������������������������������������������������������������������������������������������������������������� 167
Raising Exceptions�������������������������������������������������������������������������������������������������������������� 167
Catching Exceptions������������������������������������������������������������������������������������������������������������ 170
Raising and Reraising Exceptions��������������������������������������������������������������������������������������� 171
Catching Multiple Exceptions���������������������������������������������������������������������������������������������� 172

Chapter 8: Text View Widget��������������������������������������������������������������������������������� 175


Scrolled Windows��������������������������������������������������������������������������������������������������������������������� 175
Text Views��������������������������������������������������������������������������������������������������������������������������������� 181
Text Buffers������������������������������������������������������������������������������������������������������������������������� 182
Text View Properties������������������������������������������������������������������������������������������������������������ 184
Pango Tab Arrays����������������������������������������������������������������������������������������������������������������� 188
Text Iterators and Marks����������������������������������������������������������������������������������������������������������� 190
Editing the Text Buffer��������������������������������������������������������������������������������������������������������� 191
Retrieving Text Iterators and Marks������������������������������������������������������������������������������������� 193
Changing Text Buffer Contents�������������������������������������������������������������������������������������������� 195
Cutting, Copying, and Pasting Text��������������������������������������������������������������������������������������� 196
Searching the Text Buffer���������������������������������������������������������������������������������������������������� 199
Scrolling Text Buffers���������������������������������������������������������������������������������������������������������� 203
Text Tags����������������������������������������������������������������������������������������������������������������������������������� 204
Inserting Images����������������������������������������������������������������������������������������������������������������������� 209
Inserting Child Widgets������������������������������������������������������������������������������������������������������������� 211
Gtk.SourceView������������������������������������������������������������������������������������������������������������������������� 214
Test Your Understanding����������������������������������������������������������������������������������������������������������� 215
Exercise 1: Text Editor��������������������������������������������������������������������������������������������������������� 216
Summary���������������������������������������������������������������������������������������������������������������������������������� 216

Chapter 9: Tree View Widget��������������������������������������������������������������������������������� 219


Parts of a Tree View������������������������������������������������������������������������������������������������������������������ 220
Gtk.TreeModel���������������������������������������������������������������������������������������������������������������������� 221
Gtk.TreeViewColumn and Gtk.CellRenderer������������������������������������������������������������������������� 223

ix
Table of Contents

Using Gtk.ListStore������������������������������������������������������������������������������������������������������������������� 225


Creating the Tree View��������������������������������������������������������������������������������������������������������� 228
Renderers and Columns������������������������������������������������������������������������������������������������������ 228
Creating the Gtk.ListStore��������������������������������������������������������������������������������������������������� 230
Using Gtk.TreeStore������������������������������������������������������������������������������������������������������������������ 232
Referencing Rows��������������������������������������������������������������������������������������������������������������������� 236
Tree Paths���������������������������������������������������������������������������������������������������������������������������� 237
Tree Row References����������������������������������������������������������������������������������������������������������� 238
Tree Iterators����������������������������������������������������������������������������������������������������������������������� 239
Adding Rows and Handling Selections������������������������������������������������������������������������������������� 240
Single Selections����������������������������������������������������������������������������������������������������������������� 241
Multiple Selections�������������������������������������������������������������������������������������������������������������� 242
Adding New Rows��������������������������������������������������������������������������������������������������������������� 243
Handling Double-clicks������������������������������������������������������������������������������������������������������� 252
Editable Text Renderers������������������������������������������������������������������������������������������������������������ 253
Cell Data Methods��������������������������������������������������������������������������������������������������������������������� 255
Cell Renderers��������������������������������������������������������������������������������������������������������������������������� 259
Toggle Button Renderers����������������������������������������������������������������������������������������������������� 259
Pixbuf Renderers����������������������������������������������������������������������������������������������������������������� 261
Spin Button Renderers�������������������������������������������������������������������������������������������������������� 263
Combo Box Renderers��������������������������������������������������������������������������������������������������������� 265
Progress Bar Renderers������������������������������������������������������������������������������������������������������ 268
Keyboard Accelerator Renderers����������������������������������������������������������������������������������������� 269
Test Your Understanding����������������������������������������������������������������������������������������������������������� 273
Exercise 1: File Browser������������������������������������������������������������������������������������������������������ 273
Summary���������������������������������������������������������������������������������������������������������������������������������� 273

Chapter 10: Menus and Toolbars�������������������������������������������������������������������������� 275


Pop-up Menus��������������������������������������������������������������������������������������������������������������������������� 275
Creating a Pop-up Menu������������������������������������������������������������������������������������������������������ 276
Pop-up Menu Callback Methods������������������������������������������������������������������������������������������ 280

x
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Table of Contents

Keyboard Accelerators�������������������������������������������������������������������������������������������������������������� 283


Status Bar Hints������������������������������������������������������������������������������������������������������������������������ 287
The Status Bar Widget��������������������������������������������������������������������������������������������������������� 287
Menu Item Information�������������������������������������������������������������������������������������������������������� 289
Menu Items������������������������������������������������������������������������������������������������������������������������������� 293
Submenus��������������������������������������������������������������������������������������������������������������������������� 294
Image Menu Items��������������������������������������������������������������������������������������������������������������� 294
Check Menu Items��������������������������������������������������������������������������������������������������������������� 295
Radio Menu Items���������������������������������������������������������������������������������������������������������������� 296
Menu Bars��������������������������������������������������������������������������������������������������������������������������������� 296
Toolbars������������������������������������������������������������������������������������������������������������������������������������ 299
Toolbar Items���������������������������������������������������������������������������������������������������������������������������� 303
Toggle Tool Buttons������������������������������������������������������������������������������������������������������������� 304
Radio Tool Buttons��������������������������������������������������������������������������������������������������������������� 305
Menu Tool Buttons��������������������������������������������������������������������������������������������������������������� 305
Dynamic Menu Creation������������������������������������������������������������������������������������������������������������ 307
Creating XML Files��������������������������������������������������������������������������������������������������������������� 307
Loading XML Files��������������������������������������������������������������������������������������������������������������� 311
Test Your Understanding����������������������������������������������������������������������������������������������������������� 313
Exercise 1: Toolbars������������������������������������������������������������������������������������������������������������� 314
Exercise 2: Menu Bars��������������������������������������������������������������������������������������������������������� 314
Summary���������������������������������������������������������������������������������������������������������������������������������� 314

Chapter 11: Dynamic User Interfaces������������������������������������������������������������������� 317


User Interface Design��������������������������������������������������������������������������������������������������������������� 318
Know Your Users������������������������������������������������������������������������������������������������������������������ 318
Keep the Design Simple������������������������������������������������������������������������������������������������������ 319
Always Be Consistent���������������������������������������������������������������������������������������������������������� 320
Keep the User in the Loop��������������������������������������������������������������������������������������������������� 321
We All Make Mistakes��������������������������������������������������������������������������������������������������������� 322
The Glade User Interface Builder���������������������������������������������������������������������������������������������� 322

xi
Table of Contents

The Glade Interface������������������������������������������������������������������������������������������������������������� 323


Creating the Window����������������������������������������������������������������������������������������������������������� 326
Adding a Toolbar������������������������������������������������������������������������������������������������������������������ 330
Completing the File Browser����������������������������������������������������������������������������������������������� 333
Making Changes������������������������������������������������������������������������������������������������������������������ 335
Widget Signals��������������������������������������������������������������������������������������������������������������������� 335
Creating a Menu������������������������������������������������������������������������������������������������������������������ 337
Using Gtk.Builder���������������������������������������������������������������������������������������������������������������������� 339
Loading a User Interface����������������������������������������������������������������������������������������������������� 342
Test Your Understanding����������������������������������������������������������������������������������������������������������� 343
Exercise 1: Glade Text Editor����������������������������������������������������������������������������������������������� 343
Exercise 2: Glade Text Editor with Menus���������������������������������������������������������������������������� 343
Summary���������������������������������������������������������������������������������������������������������������������������������� 344

Chapter 12: Custom Widgets�������������������������������������������������������������������������������� 345


An Image/Label Button�������������������������������������������������������������������������������������������������������������� 345
Custom Message Dialogs���������������������������������������������������������������������������������������������������������� 349
Multithreaded Applications������������������������������������������������������������������������������������������������������� 351
The Proper Way to Align Widgets���������������������������������������������������������������������������������������������� 358
Summary���������������������������������������������������������������������������������������������������������������������������������� 361

Chapter 13: More GTK Widgets����������������������������������������������������������������������������� 363


Drawing Widgets����������������������������������������������������������������������������������������������������������������������� 363
A Drawing Area Example����������������������������������������������������������������������������������������������������� 364
The Layout Widget��������������������������������������������������������������������������������������������������������������� 370
Calendars���������������������������������������������������������������������������������������������������������������������������������� 371
Printing Support������������������������������������������������������������������������������������������������������������������������ 373
Print Operations������������������������������������������������������������������������������������������������������������������� 378
Beginning the Print Operation��������������������������������������������������������������������������������������������� 382
Rendering Pages����������������������������������������������������������������������������������������������������������������� 383
Finalizing the Print Operation���������������������������������������������������������������������������������������������� 384

xii
Table of Contents

Cairo Drawing Context�������������������������������������������������������������������������������������������������������������� 384


Drawing Paths��������������������������������������������������������������������������������������������������������������������� 385
Rendering Options��������������������������������������������������������������������������������������������������������������� 386
Recent Files������������������������������������������������������������������������������������������������������������������������������ 387
Recent Chooser Menu��������������������������������������������������������������������������������������������������������� 394
Adding Recent Files������������������������������������������������������������������������������������������������������������� 395
Recent Chooser Dialog�������������������������������������������������������������������������������������������������������� 396
Automatic Completion��������������������������������������������������������������������������������������������������������������� 397
Test Your Understanding����������������������������������������������������������������������������������������������������������� 399
Exercise 1: Creating a Full Text Editor��������������������������������������������������������������������������������� 399
Summary���������������������������������������������������������������������������������������������������������������������������������� 400

Chapter 14: Integrating Everything���������������������������������������������������������������������� 403


File Browser������������������������������������������������������������������������������������������������������������������������������ 403
Calculator���������������������������������������������������������������������������������������������������������������������������������� 405
Ping Utility��������������������������������������������������������������������������������������������������������������������������������� 406
Calendar������������������������������������������������������������������������������������������������������������������������������������ 408
Markup Parser Functions���������������������������������������������������������������������������������������������������� 409
Parsing the XML File������������������������������������������������������������������������������������������������������������ 410
Further Resources��������������������������������������������������������������������������������������������������������������������� 410
Summary���������������������������������������������������������������������������������������������������������������������������������� 411

Appendix A: GTK+ Properties������������������������������������������������������������������������������� 413


G
 TK+ Properties������������������������������������������������������������������������������������������������������������������������ 413
Child Widget Properties������������������������������������������������������������������������������������������������������������� 475

Appendix B: GTK+ Signals������������������������������������������������������������������������������������ 481


E vents��������������������������������������������������������������������������������������������������������������������������������������� 482
Widget Signals�������������������������������������������������������������������������������������������������������������������������� 485

xiii
Table of Contents

Appendix C: GTK+ Styles�������������������������������������������������������������������������������������� 537


Default RC File Styles���������������������������������������������������������������������������������������������������������������� 537
Pango���������������������������������������������������������������������������������������������������������������������������������������� 537
Gtk.TextTag Styles��������������������������������������������������������������������������������������������������������������������� 540

Appendix D: Exercises Solutions and Hints���������������������������������������������������������� 545


Chapter 3, Exercise 1: Using Events and Properties����������������������������������������������������������������� 545
Chapter 4, Exercise 1: Using Multiple Containers��������������������������������������������������������������������� 546
Chapter 4, Exercise 2: Even More Containers��������������������������������������������������������������������������� 547
Chapter 5, Exercise 1: Renaming Files�������������������������������������������������������������������������������������� 547
Chapter 5, Exercise 2: Spin Buttons and Scales����������������������������������������������������������������������� 548
Chapter 6, Exercise 1: Implementing File Chooser Dialogs������������������������������������������������������� 549
Chapter 8, Exercise 1: Text Editor���������������������������������������������������������������������������������������������� 549
Chapter 9, Exercise 1: File Browser������������������������������������������������������������������������������������������ 550
Chapter 10, Exercise 1: Toolbars����������������������������������������������������������������������������������������������� 551
Chapter 10, Exercise 2: Menu Bars������������������������������������������������������������������������������������������� 554
Chapter 11, Exercise 1: Glade Text Editor���������������������������������������������������������������������������������� 556
Chapter 11, Exercise 2: Glade Text Editor with Menus�������������������������������������������������������������� 557
Chapter 13, Exercise 1: Full Text Editor������������������������������������������������������������������������������������� 558

Index��������������������������������������������������������������������������������������������������������������������� 561

xiv
About the Author
W. David Ashley is a technical writer for SkillSoft, where he
specializes in open source, particularly Linux. As a member
of the Linux Fedora documentation team, he recently led
the Libvert project documentation and wrote the Python
programs included with it. He has developed in 20 different
programming languages during his 30 years as a software
developer and IT consultant. This includes more than
18 years at IBM and 12 years with American Airlines.

xv
About the Technical Reviewers
Jonathan Giszczak is a professional software developer with
extensive experience writing software for the military and
financial services industries, as well as the game industry.
He graduated from the University of Michigan with a degree
in computer engineering. He has been writing C, C++, and
Python applications since the 1990s, including applications
in Motif and PyGTK.

Peter Gill loves spending time with his family in


Newfoundland, Canada. He is currently a software
developer at TownSuite, where he specializes in release
deployment and leading a full stack web development
team. Peter loves learning programming language and has
used Python, Ruby, Rust, Io, Prolog, Java, C, C++, C#, VB,
JavaScript, Typescript, Bash, PowerShell and is currently
focused on C# with ASP .NET Core and Typescript. He
is a huge advocate open source software. He loves to use
Git, Jenkins, Docker, and other tools related to automated
deployments.

xvii
Acknowledgments
I would like to express my gratitude to the many people who have made this book
possible. Many thanks go to Daniel Berrange of Red Hat, whose assistance has certainly
decreased the number of errors in the book. I would also like to thank Peter Gill and
Jonathan Giszczak for their fine technical reviewing skills. You were very tough on every
paragraph I wrote and every example I coded, but this book is better today because of
the hard work you put into the project.
I would like to extend a special thanks to Andrew Krause for his encouragement and
help. Without him, this update to his original book would not have been possible.
In addition, I would like to thank the people at Apress who put so many hours of
hard work into the book. I could not imagine writing for any other publisher. It is a great
organization that makes the writing process enjoyable.
Finally, I need to acknowledge my wife, who has supported me in every step of the
process. Without you, I would not be who I am today and for that I am forever grateful.

—W. David Ashley

xix
Introduction
One of the most important aspects of an application is the interface that is provided to
interact with the user. With the unprecedented popularity of computers in society today,
people have come to expect those user interfaces to be graphical, and the question of
which graphical toolkit to use quickly arises for any developer. For many, the cross-­
platform, feature-rich GTK+ library is the obvious choice.
Learning GTK+ can be a daunting task, because many features lack documentation
and others are difficult to understand even with the API documentation. Foundations
of PyGTK Development aims to decrease the learning curve and set you on your way to
creating cross-platform graphical user interfaces for your applications.
Each chapter in this book contains multiple examples that help you further your
understanding. In addition to these examples, the final chapter of this book provides
five complete applications that incorporate topics from the previous chapters. These
applications show you how to bring together what you have learned to accomplish in
various projects.
Each chapter starts with an overview, so that you are able to skip around if you
want. Most chapters also contain exercises to test your understanding of the material. I
recommend that you complete all the exercises before continuing, because the best way
to learn GTK+ is to use it.
At the end of this book, there are multiple appendixes that serve as references for
various aspects of GTK+. These appendixes include tables listing signals, styles, and
properties for every widget in GTK+. These appendixes will remain a useful reference
after you have finished reading the book and begin creating your own applications. In
addition, Appendix D explains the solutions to all the exercises in the book.

Who Should Read This Book


Because this book begins with the basics and works up to more difficult concepts, you do
not need any previous knowledge of GTK+ development to use this book. This book does
assume that you have a decent grasp of the Python programming language. You should

xxi
Introduction

also be comfortable with running commands and terminating applications (Ctrl+C) in a


Linux terminal.
In addition to a grasp of the Python programming language, some parts of this book
may be difficult to understand without some further knowledge about programming
for Linux in general. You will get more out of this book if you already comprehend basic
object-oriented concepts. It is also helpful to know how Linux handles processes.
You can still use this book if you do not already know how to implement object
orientation or manage processes in Linux, but you may need to supplement this book
with one or more online resources. A list of helpful links and tutorials can be found
on the book’s web site, which is located at www.gtkbook.com. You can also find more
information about the book at www.apress.com.

How This Book Is Organized


Foundations of PyGTK Development is composed of 14 chapters. Each chapter gives you
a broad understanding of its topic. For example, Chapter 4 covers container widgets and
introduces many of the most important widgets derived from the Gtk.Container class.
Because of this structure, some chapters are somewhat lengthy. Do not feel as
though you have to complete a whole chapter in one sitting, because it can be difficult
to remember all the information presented. Also, because many examples span multiple
pages, consider focusing on just a few examples at a time; try to understand their syntax
and intent.
Each chapter provides important information and unique perspectives that help you
to become a proficient PyGTK developer.
Chapter 1 teaches you how to install the GTK+ libraries and their dependencies on
your Linux system. It also gives an overview of each of the GTK+ libraries, including
GObject, GDK, GdkPixbuf, Pango, and ATK.
Chapter 2 introduces the Gtk.Application and Gtk.ApplicationWindow classes.
These classes are fundamental classes that wrap the program logic and provide some
useful features for your application. While a GTK+ program can be written without
utilizing these classes, you will find the creation process much easier and more object-­
oriented if you utilize these classes.
Chapter 3 steps through two Hello World applications. The first shows you the basic
essentials that are required by every GTK+ application. The second expands on the first

xxii
Introduction

while also covering signals, callback functions, events, and child widgets. You then learn
about widget properties and the Gtk.Button and Gtk.Label widgets.
Chapter 4 begins by introducing the Gtk.Container class. Next, it teaches you about
horizontal and vertical boxes, grids, fixed containers, horizontal and vertical panes,
notebooks, and event boxes.
Chapter 5 covers basic widgets that provide a way for you to interact with users.
These include toggle buttons, specialized buttons, text entries, and spin buttons.
Chapter 6 introduces you to the vast array of built-in dialogs. It also teaches you how
to create your own custom dialogs.
Chapter 7 is a general overview of the most useful features of Python. It covers many
Python features that are directly useful to the GTK+ programmer but not necessarily
covered in depth in many Python introductory texts.
Chapter 8 introduces you to scrolled windows. It also gives in-depth instructions on
using the text view widget. Other topics include the clipboard and the Gtk.SourceView
library.
Chapter 9 covers two types of widgets that use the Gtk.TreeModel object. It gives an
in-depth overview of the tree view widget and shows you how to use combo boxes with
tree models or strings.
Chapter 10 provides two methods of menu creation: manual and dynamic. It covers
menus, toolbars, pop-up menus, keyboard accelerators, and the status bar widget.
Chapter 11 is a short chapter about how to design user interfaces with the Glade user
interface builder. It also shows you how to dynamically load your user interfaces using
Gtk.Builder.
Chapter 12 teaches you how to create your own custom GTK+ widgets by deriving
them from other widgets.
Chapter 13 covers many of the remaining widgets that do not quite fit into other
chapters. This includes several widgets that were introduced in GTK+ 2.10, including
recent files and tray icon support.
Chapter 14 gives you a few longer, real-world examples. They take the concepts you
have learned throughout the book and show you how they can be used together.
The appendixes act as references to widget properties, signals, styles, stock items,
and descriptions of exercise solutions.

xxiii
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Introduction

Official Web Site


You can find additional resources on the book’s official web site, found at www.gtkbook.com.
This web site includes up-to-date documentation, links to useful resources, and articles
that supplement what you learn in this book. There is also find a link to the downloadable
source code for every example in this book. The Apress web site (www.apress.com,) is
another great place to find more information about this book.
When you unzip the source code from the web site, you will find a folder that
contains the examples in each chapter and an additional folder that holds exercise
solutions. You can run all the files within the current folder.

xxiv
CHAPTER 1

Getting Started
Welcome to Foundations of PyGTK Development. In this book, you acquire a thorough
knowledge of the GIMP Toolkit (GTK+), which allows you to create comprehensive
graphical programs. Before continuing, you should be aware that this book is aimed at
Python programmers, so we assume that you already have a good understanding of the
Python language, and you can jump right into using GTK+. Time is not spent on bringing
you up to speed on Python.
To get the most out of this book, you should follow each chapter sequentially and
study all the examples in each chapter. Getting started with GTK+ on Linux is very easy
because most distributions are bundled with everything you need to create and run
Python/GTK+ programs. We cover Windows and macOS installation procedures later in
this chapter.
There are a few tools that should be installed to get you started without running
into trouble. First, Python 3.x should be installed. It is required to run GTK+ 3.x Python
programs. Second, the GTK+ 3.x runtime libraries should be installed. These libraries
come with many dependencies installed, including GObject, Pango, GLib, GDK,
GdkPixbuf, and ATK. Be sure to install all the dependent libraries.
You do not need to install the GNU Compiler Collection. You are not compiling any
C/C++ programs in the examples provided in this book. You only need Python 3.x and
the GTK+ 3.x runtime libraries to be installed to run the example programs.

Differences Between GTK+ 2.x and 3.x


If you are proficient in GTK+ 2.x, you may be surprised by the changes in version 3.x.
There are both small and large changes to the GTK+ API and the Python classes that
wrap those libraries. While the basics for most widgets are unchanged, there are a lot
of small “gotchas” that can cause you grief until you understand why and where the
changes have been made.

1
© W. David Ashley and Andrew Krause 2019
W. D. Ashley and A. Krause, Foundations of PyGTK Development,
https://doi.org/10.1007/978-1-4842-4179-0_1
CHAPTER 1 Getting Started

The reason for most of these changes is due to a change in the GTK+ philosophy. The
GTK+ 2.x libraries were designed around consistency between all GTK+ programs, with
the use of GTK+ themes as the basis for that consistency. This philosophy completely
changed with the GTK+ libraries. While themes are still available, it is now easier to
create GTK+ programs that have their own look and feel separate from the current
GTK theme. While this gives the developer greater control, it also requires some extra
programming steps to achieve the look and feel. It also removes some APIs that make a
widget easy to create and control.
The following is a partial list of the differences between GTK+ 2.x and 3.x. Some of these
items have simple workarounds, but others require a little more work on the programmer’s
part because they are different enough to cause source code porting problems.

• Many standard stock icons have been removed, mostly the ones used
on push buttons and menu items. If you need these icons, you must
provide your own set.

• All the 2.x constants are now grouped in a 3.x Python class as
attributes. If you are porting source code, this is a major area that
needs to be addressed.

• Some containers have been eliminated. For instance, the Gtk.Hbox


and Gtk.Vbox widgets have been removed and you now must specify
the orientation of a Gtk.Box via a parameter when creating a new
Gtk.Box instance. Note that the Gtk.Box class is now a real class in
GTK+ 3.x, not an abstract class.

• Default packing for containers has been removed; all packing


parameters must be supplied to the API.

• Some standard dialogs have been removed. You must create your
own dialogs to replace them.

• There are two new major classes that are very useful for the overall
control of large and small applications: the Gtk.Application class
and the Gtk.ApplicationWindow class. While these classes are not
strictly needed for simple applications, you still find them useful
for even the simplest of applications. For that reason, we base all
the examples in this book on these two classes to wrap our widget
examples.

2
CHAPTER 1 Getting Started

Creating menus is much easier using the Gtk.Application and Gtk.ApplicationWindow


classes. This required complex programming in the GTK+ 2.x environment and is reduced to
creating an XML file to represent the menu you want to create in the 3.x environment.

Installing GTK+ 3.x


Before you can create programs, you must install Python, GTK+, and all the dependent
libraries. This section covers installing GTK+ on Linux and other Unix-like operating
systems. It does not cover how to install GTK+ on macOS or Windows. You need to
research the correct way to install GTK+ and Python in those OS environments.
Most modern Linux distributions include Python and GTK+ as part of their
respective repositories. You simply need to select Python 3 (this is sometimes installed
by default) and GTK+ 3.x (use the latest version available, as shown in Figure 1-1) from
the package install program in your Linux distribution and then install those packages
along with all the dependent packages.
To test your installation, run the following command.

/usr/bin/gtk3-demo

Figure 1-1. GTK+ 3 demo program


3
CHAPTER 1 Getting Started

If the program exists and the widget documentation window appears, then the GTK+
installation was successful.

S
 ummary
This chapter introduced GTK+ Version 3.x and Python 3 along with some installation
prerequisites. It presented some post-installation tests to ensure that GTK+ was
successfully installed. And it discussed some differences between GTK+ 2.x and 3.x.
After successfully installing GTK+ 3.x and Python 3, your environment should be
ready to build your first Python/GTK+ program.
Chapter 2 further discusses Gtk.Application and the Gtk.ApplicationWindow, the
base classes that you should use for all Python 3 GTK+ 3.x programs.

4
Random documents with unrelated
content Scribd suggests to you:
defence of which was still committed to our shattered regiment by Sir
Alexander Leslie, who put implicit trust in us. I had it dressed by a passing
surgeon, as I had no wish to risk myself near the frightful hospitals; and, on
the firing ceasing, I went to visit Ernestine.

I found her in the little boudoir, and there was something about it and her
too, that alarmed me; but then, perhaps, I was weak and nervous; provisions
were so scarce that, though she knew it not, I had tasted nothing for two
days. She was reclining in a large gilded fauteuil of yellow damask, stuffed
with down, and her tiny feet rested on a tabourette of the same.

The room was darkened by the blinds being closely drawn; but the
windows were open, and through them there swept a warm breeze, that
played with the heavy hangings of velvet, and wafted the perfume of
flowers from a large stand of green-painted wood bearing three rows of
Dresden china vases, each containing the few flowers of the season.

She was dressed in white satin, brocaded with red flowers; it was a dress
I had given her; and to please me, doubtless, she had put it on, together with
a pair of beautiful pearl bracelets, for which I had given to one of Karl's
pistoliers six dollars, without asking him any questions.

"Dear Ernestine, you are unwell!" said I, on perceiving that she made but
a languid motion of her hand as I approached her.

"No, no!" she replied; "but the memory of all I saw yesterday affects me
still—and these decayed flowers, perhaps—there, thank you," she added, as
I flung the flowers referred to into the street.

She looked very pale, and I thought the tone of her voice was altered.

Next day she was even paler, and her languid air was unmistakeable. The
room was shaded as before, and she sat near the half-opened window, to
enjoy the cool breeze that swept over the Sound of Rügen. I hoped it was
merely the deprivation of many little luxuries with which I had contrived to
furnish her, long after every one else in Stralsund had ceased to think of
them. Prudentia and her spouse had kindly sent me some of these things;
but a few days before I had visited the shop at the corner of the Bourse, and
found it closed, with a red cross chalked on the door. The plague had been
there, and the drivers of the death carts were to call for the dead on their
way to the trenches.

Instead of being curled according to the fashion, in little ringlets all


round her charming face, Ernestine had her black hair smoothly and plainly
braided over her temples; her dress was still the white brocade with the
pearl bracelets; but to-day, although her face was paler still, she assured me
with a smile, that she was "quite well."

She remained with her left cheek resting upon her hand, and when
caressingly I attempted to kiss it, I felt as if an arrow had pierced my heart,
on perceiving that which she had been striving to conceal from me—a
round hectic mark, about the size of a dollar.

It was the plague spot!

Some frivolous remark, the natural impulse of a toying lover, died away
on my lips as I saw this horrible mark, and with agony became convinced
that the finger of death had printed it there. I glanced at her face.

It seemed so much paler since yesterday! It was cold, frozen, and sad
looking, even when she strove to smile. Its beauty had become severe, and
she seemed taller than usual in her long white stomacher. In that darkened
room she looked like a white spirit, or a statue of snowy marble. Her eyes
had lost their beautiful language. Sadness, intense sadness, alone remained.

"Ah! do not touch me," said she, withdrawing her hand; "leave me,
Philip—leave me now!"

"Ernestine!" I exclaimed, and passionately clasping her to my breast,


burst into tears.

She endeavoured to elude me, and begged, entreated, and implored me


to leave her, lest I, too, might perish by her fatal touch; but I wished for
nothing more. Yet I hoped she might be saved, and starting from her side, I
summoned Gillian M'Bane, and despatched him for Doctor Pennicuik; I
then summoned Ernestine's female attendants, who had her placed in bed.
In two hours I saw her again.

She was delirious, and imagined herself with Gabrielle and her father.
Her once beautiful eyes had become bloodshot and red as coral; there was a
little line of foam round her lips, and spots of purple were on her cheeks
and brow.

Oh, the agony of a sight like that! Honest Pennicuik, hurried me roughly
but kindly out of her apartment, and, thrusting me into a fauteuil, made me
drink a glass or two of his medicated hospital wine.

Let me hurry over the relation and the memory of those sad hours of
hopeless sorrow and futile anxiety.

On the second day, the fever and the delirium passed away, and I was
permitted to see her; for Father Ignatius, with more than usual gravity on
his long and solemn face, came to tell me that she was dying.

Dying! The good man gave me his arm, for I was very weak, and a
partial blindness had come over me. I hoped it was the plague, that I might
go with Ernestine; but, alas! it was only the result of sheer hunger, grief,
and excitement.

I stood by her bedside in that darkened chamber, the features of which


are still before me; its atmosphere was close and sickly; there were vials
and bottles, cups and cordials, and between the festooned curtains a pale
and sickly face, with inflamed eyes and purple spots upon a snowy skin,
that contrasted powerfully with two massive braids of sable hair. And this
was Ernestine!

Kneeling down by the side of the bed, I stooped my brow upon her thin
wan hand, and wept as if my heart would burst. Ernestine also wept, but in
silence; tear after tear rolled over her hollowed cheek, for she was too
feeble to raise her head, and we muttered only incoherent sentences of
sorrow and endearment—which it were useless to commit to paper; for to
some they might seem exaggerated—to others perhaps too cold and
passionless; as I can neither impart to them nor to the reader, the agony that
thrilled our hearts, though the memory of that keen agony yet lingers in my
soul, like an old and painful dream.

In expression her eyes were sad and fixed; there was a smile of ineffable
sweetness playing about her thin white lips; but the dew of death was on her
brow and about her braided hair. Believing that she was about to rejoin her
sister, the poor girl said to me—

"I have been praying for you, and for myself—thus, like St. Monica,
sending my most pious thoughts as harbingers to heaven. I am going to
Gabrielle—ah, how she loved me!"

I could only murmur her name; then she put forth her dear lip
affectionately for one more kiss. I became bewildered, and an emotion of
wild satisfaction stole into my heart.

"'Tis the plague—it has seized me, too!" I muttered joyfully. "Dear
Ernestine, I will soon follow you!"

The film was again spreading over my eyes, and there was a hissing in
my ears; yet I felt the cold hand of Ernestine clasped in mine, and knew that
its grasp was relaxing.

Then I heard the voice of honest Father Ignatius saying in my ear, and
with a voice rendered husky by emotion—

"She is dead—God receive her sinless soul! close her eyes, and kiss her,
Philip—all is over now."

At that moment I heard the wheels of the dead cart rattling over the
street, and the jangle of its hateful bell.

Of that mournful day, I remember no more!

****

Next day I recovered, as one who awakes from a deep sleep, and all the
events of yesterday rushed like a torrent of grief and pain upon my mind.
Father Ignatius, who had relapsed into his immobility of aspect and
demeanour, knelt at the fauteuil, reading his daily office out of a little brass-
bound breviary, which he closed the moment I moved. I was lying on the
floor, with a cloak spread over me.

"Would you like to see her?" he asked, in a voice of kindness.

"Lead me there, if you please."

"Then, I pray you, follow me."

I stood in the chamber of death, and there was in it an awful stillness that
deeply impressed me.

She was dead—this being, whom I had loved with my whole heart, and
with my whole soul, was dead! yet I had neither a prayer nor a tear. I could
neither form one, nor yield the other. I was frozen—stunned! She was dead!
and these three words seemed written before me every where; there was a
horrid stillness in my heart, and in every thing around me. The whole world
seemed to be standing still; and what was now my Ernestine?

I looked upon her, but could not realize her death. The dark hair, which
she was wont to dress so gracefully, was smoothed in modest braids over
her pale and stonelike brow. They were very still—those glossy braids; and
not a breath of air disturbed them, though the breeze lifted the leaves of her
now neglected flowers. Her birds were chirping near, for their seed-boxes
were empty now; the Jesuit observed this, and, notwithstanding all his
sternness, even at that dreadful time he filled them, for the old man's heart
was a very kind one.

Her eyes—those deep, dark, glorious eyes—were sightless now; turned


back within their snow-white lids, from which the long lashes fell upon her
marble cheek. Her nose seemed to have become too aquiline, too pointed
and thin, for that of Ernestine; and then the lips—those cold, thin, purple
lines—were compressed and rigid; but yet some beauty still was lingering
there.

On the second day my Ernestine changed; her features became


contracted and livid. Oh, my God! It was a mere yellow masque! I
shuddered as I spread a veil over her, and could trust myself to gaze no
longer.

I remembered that Gabrielle looked like a sleeping angel; but my


Ernestine, more beautiful in life, was becoming ghastly and terrible in
death.

"Oh, can this indeed be her who loved me so well!" was frequently my
mental exclamation.

Oh, for one more glance—one respiration more! But the horrible
stillness was unbroken; decay would come, but never again a glance or a
smile.

I remembered now the charming delicacy, the fondness and reverence,


with which she had arranged poor Gabrielle's remains for the grave, and
would permit no other hands than hers to touch them. Now, she herself,
whose sentiment had been so fine, so delicate, so noble, was but a poor
corpse, too; but there was no sisterly hand to smooth her tresses, and
arrange the ghostly garments of her long repose. She was left completely to
strangers and hard-hearted followers of the camp.

I feared I would become mad, and so forget all about the plague and the
siege; but I never left her side until the second day, when a tremendous
salvo from the camarade battery made my heart leap within me; and then I
heard the rattling drum and the yelling bagpipe summoning our soldiers to
the walls. A new thought seized me!

I kissed her soft cheek, and that cold lip, whose icy touch sent a thrill of
horror and agony to my heart; then, grasping my claymore, I threw myself
at the head of my company, and rushed to the last defence of the
Frankendör, with a deep and settled resolution to fall—to die!
CHAPTER XLVII.

LAST ASSAULT OF STRALSUND.

I found that a salvo had completely breached the curtain of the bastion at
the Frankendör; that the debris of fallen masonry, wooden platforms,
cannon and their carriages, had half filled up the ditch before the gap; and
that a strong column of Imperialists were advancing to a general assault, led
by several officers on horseback, one of whom wore that large red plume
for which the Count of Carlstein was so remarkable. Another, who was
generally by his side, rode a magnificent white horse, and wore a cuirass
and helmet which glittered like silver in the sun, being of the most beautiful
workmanship; while his scarf, gloves, holsters, and housings, were fringed
with the richest bullion.

This cavalier was the great Duke of Friedland himself, and the place
where he rode, at the head of that advancing column, was the mark of
nearly a thousand muskets; for the Lord Spynie's regiment of Lowland
Scots was now brigaded with ours, but both were greatly reduced in
number; and a line of hollow-eyed and pale-visaged men they were; yet as
desperate as the most resolute valour, goaded by starvation and disease,
could make them.

Three strong regiments advanced to the attack;—one was the battalion of


Camargo; another was the Spanish Arcabuziers of Coloredo; and in front
was the regiment of Merodé, led by six soldiers, bearing on their shoulders
a black coffin!

Within that coffin was Merodé, whom De Vart had slain by a mortal
wound; but whose dying injunctions were, that, dead or living, he should
head the assault of Stralsund. Ruffians though they were, his soldiers had a
wild species of love for him; and now sword in hand, and shoulder-high, six
of them bore his coffin towards the breach, the fire from whence, by
frequently killing the bearers, threw the dead man heavily on the earth.
"Gentlemen and comrades," said Sir Donald; "pikemen and musketeers
—to your duty, and do it according to your wont! Remember how many
generations of our ancestors, all brave men, who loved the battle as a
pastime, are this day looking down upon you from the place of the good
man's reward in heaven."

"Dirk and claymore! dirk and claymore!" cried our men, and the shout
was heard above the roar of the musketry.

"Yes!" said Ian emphatically, as he shook his lofty plumes; "in Heaven's
name let it be dirk and claymore! I would rather meet those fellows hand to
hand, in the good old Highland fashion, than by bandying bullets from
behind a stone-dyke. Let us this day save Stralsund, or perish with her!"

"Better it is to die by musket-shot, than by starvation or the plague,"


grumbled Phadrig Mhor.

"Ian," said I, "you have still something to live for. Remember Moina!"

"True," said he; "Moina is here—in my eyes and in my heart. My life is


hers."

"Then why throw it heedlessly away? Do you live for her? 'Tis enough
for the wretched to perish."

He wrung my hand, and we passed to our places.

On this day of carnage and desperation the world was looking as bright
as ever. The walls of the old city were smiling in the sunshine, and its
ruddiest glow fell on the ancient church, within the walls of which there
was the greatest amount of suffering. Though the season was advanced, the
noon was somewhat sultry, and swarms of new-born gnats were wheeling in
the sunny air. The young green grass was sprouting above the trenches
where the dead were buried; the Sound was like a blue mirror, and clouds of
fleecy whiteness flecked the wide azure dome of the sky. All nature looked
beautiful, and the glad earth seemed to smile back on the bright sun; but
man, in his Wickedness, was doing all he could to render that beautiful
Earth—a Hell!
I had just come from the lifeless Ernestine, and hence, perhaps, this
moralizing for a moment; but I was dogged and desperate; selfishly caring
not who fell, or who survived—who might be victorious, or who
vanquished. The world and I had no longer any thing in common; and now
the uproar and strife that deepened round me as the foe drew near, were a
congenial relief to my tortured spirit; for it rose, as it was drawn away from
bitter thoughts, and my heart leaped at the rattling musketry, the shrieks,
cries, and moans of the wounded, the tumultuous shouts of the combatants
as they closed up shoulder to shoulder in the breach, where our Highlanders
shot, with rapid and deadly precision, right over the heads of a stand of
Spynie's Lowland pikes, whose gallant breasts had replaced the fallen
bastion.

On came that triple column of the foe, and now one high discordant yell
announced that they were within pistol-shot; but so thick was the smoke
before us that we could scarcely see them. The wild Merodeurs made
incredible efforts to bring on the coffin of their colonel, and seemed to
enjoy the strange bravado of being led by a corpse to the assault; but every
relay of soldiers who lifted it from the earth were shot down in succession,
until at last the coffin, with its bearers and hundreds of others, tumbled pell-
mell into the ditch, before the breach, the way to which became literally
choked by the bodies of the killed and wounded; and over these the rear
companies of the Merodeurs, and Camargo's Spanish pikemen, rushed
mingling to the assault, like a flood of valour and fury.

But the flood was stemmed, and that fury curbed by the hedge of
Scottish pikes that met them in the breach, and the Spaniards and Germans
were rolled back on each other, until the front ranks were literally hurled
headlong on the rear. In vain, by clubbed muskets, by hewing with swords,
and by grasping with the bare hand, they strove to beat, to cut, or tear a
passage through the soldiers of Lord Spynie. The finest chivalry of
England, of Normandy, and Acquitaine, had failed, on fields of more than
European renown, to force a passage through a rampart of Scottish pikes;
and now, assuredly, that honour was not reserved for the Imperialists of the
Duke of Friedland. Some, however, were torn out of Spynie's ranks, and
slain or taken prisoner; among the former was the son of the Laird of Leys,
first private gentleman of a company; and, among the latter, Sir John Hume
of Aytoune, in the Merse. He was dragged by the throat and waist-belt into
the midst of the enemy, by whom he was barbarously slashed and wounded.

Over the heads of Spynie's men, and closing up into their ranks, our
Highland musketeers poured their bullets point-blank into the faces of the
stormers; while our brass cannon, from an angle of the bastion, raked their
column in flank. Here they slew many of our best men; and Lumsden, my
lieutenant, Captain M'Donald, of the house of Keppoch, and nearly three
hundred gallant clansmen, fell to rise no more. We shot down all the
mounted officers, save those two who had been so conspicuous, one by his
red plume, the other by his snow-white horse; and, during the lulls of the
smoke and uproar, they were to be seen and heard encouraging their
soldiers, by precept and example, to push on, and to die rather than flinch.

"That is Rupert-with-the-Red-plume!" I heard Sir Donald say; "and he


on the white horse is the Duke of Friedland; for who but he would have the
black buffalo's head of Mechlenburg on his saddle-cloth? Fifty Scottish
pounds to the man who knocks them both on the head!"

But they seemed to bear charmed lives, and though innumerable shots
were fired at them through openings in the smoke, they were never hit; and
now, fortunately for us, at the very moment our ammunition was beginning
to fail, the enemy began to waver; and at such a time, and on such a duty, to
waver is but a prelude to flight. They gave way on all hands, and retired
with precipitation round the right flank of the Frankenlake, leaving behind
them a terrible scene of carnage and destruction.

The killed lay in hundreds, and the wounded screaming for water,
groaning, rolling, and throwing up their hands and feet, lay in hundreds
more, among scattered arms, drums, standards; and then the horrors of the
fosse, where a seething mass of living and dead lay piled over each other,
head and heels, endwise and crosswise, trod upon, and pierced in a
thousand places by the storm of shot that had augmented their number
every moment, piling up a hecatomb of slain above the abandoned coffin of
the once terrible and reckless Merodé! Among their fallen riders, even in
the ditch, as well as on the approach thereto, lay many noble horses,
maddened by pain, kicking, plunging, snorting, and shrieking (for a horse,
at times, can utter a frightful cry), as they rolled over the helpless wounded,
with their iron hoofs breaking legs and ribs, or beating out the brains of
those whom the musket-shot had already maimed elsewhere. Use and wont
made us regardless of this scene; and now we were sufficiently attracted by
another.

While the fugitives were retiring round the angle of the Frankenlake, the
two mounted officers already mentioned, were frequently seen
endeavouring to rally them, and placing their horses before the flying
bands; but they might as well have striven to stay the waves of ocean. At
last they appeared to quarrel with each other; we saw their swords gleam as
blows were given and thrusts exchanged; their horses reared up, and then
plunged past each other; a blade flashed in the sun, and the cavalier on the
white horse was struck from his saddle; his charger galloped away, and
while he had to limp after his soldiers on foot, the officer with the red
plume came galloping madly back towards the breach, waving a white
handkerchief to us in sign of truce or peace. Several shots were fired after
him by the Merodeurs, but, escaping them, he cleared the corpse-
encumbered ditch by one terrific bound, and forcing his noble horse up the
rough avalanche of masonry, dismounted in the midst of us, breathless,
panting, pale with excitement, anger, and exertion.

"The Count of Carlstein! Rupert-with-the-Red-plume!" cried a hundred


voices, in every varying accent of astonishment.

"Ay, gentlemen, your countryman! no longer, I fear, Rupert Count of


Carlstein, but simply old Philip Rollo, the soldier of fortune that fate saw
him thirty years ago. By one blow of my sword—the same which, not a
minute ago, unhorsed that mighty, ambitious, and intolerable tyrant, the
Duke of Friedland—I have demolished one of the fairest fortunes that ever
a stanch soldier secured by the toil and dangers of a life that can never be
lived again. Receive me, I pray you, as your countryman, as a poor and
penniless soldier, who comes to seek service under the Swede and Dane."

The count spoke with bitterness, and breathed hard as he leaned on his
sword, and our regiment closed round him with surprise and inquiry.
Unwilling to tell what I knew would be as poniards in his heart (the fate of
Ernestine), I stood a little in the background; while Marshal Leslie, Sir
Donald Mackay, and Lord Spynie, all together inquired the cause of quarrel
with his general. After taking a sip or two of brandy from the flask of Ian
Dhu, and retiring a little apart from the vicinity of the breach—

"You are well aware, gentlemen," said he, "how signal has been the
success attending the arms of the emperor and princes of the Catholic
League. Driven from Juteland, Christian IV. has been glad to seek shelter by
sea, and by wandering among the Danish isles, and the career of conquest
has only been stopped by the waters of the Baltic——"

"And the Scottish infantry," interposed old Leslie.

"Yes, marshal, but that I considered as understood. I have long foreseen


that this ambition will destroy itself. The combination of the northern kings
is what Wallenstein most dreads and hates, as it prevents him obtaining a
solid hold upon the Baltic, and from penetrating into Sweden for his own
ends, though in the emperor's name. At a great council of war held lately in
Vienna, I threw out some hints of Wallenstein's hopes of founding a
separate power in northern Europe—a power of which himself would be the
head. I represented to the emperor the necessity of making peace with
Christian IV. before he invaded Sweden, urging that he could never
withstand a union of the northern princes with the hostile Protestants of the
empire. The emperor was pleased to hearken to me, and, desirous of peace,
despatched me to Stralsund here, with written powers to treat with
Christian; these powers he afterwards dared to repudiate, and Wallenstein,
who—far from wishing a peace, which would reduce him to a mere civilian
again—hopes in the general confusion to achieve such ends as no man hath
conceived since the days of Alexander of Macedon, dared to destroy my
credentials before my face—yea, but yesterday in council! Hence our high
words to-day, under the very muzzles of your cannon. When, enraged by
the useless slaughter of which he was the cause, I accused him of daring
and criminal ambition, blows were exchanged, and by one I hurled him to
the earth, and cut myself off from the empire for ever."

How truly the count had judged of the character of the great Duke of
Friedland (or the Archduke of Mechlenburg, as he was generally styled for
a time), after events have shown; for they brought to pass that dark scene in
the Bohemian Castle of Eagar, where the Scottish colonels, Leslie and
Gordon, were compelled to hew off his head in the banqueting hall.
"Ah! here is my friend and namesake, Captain Rollo," said the count,
approaching me; "and so, comrade, you have still preserved the gold chain I
gave you on that moonlight night by the marshy Elbe. But what is the
matter? you look pale as Banquo's ghost. I see starvation in every eye here.
Now lead me to my poor girl—the last that fate has left me; for if I have her
in my arms, the county of Carlstein, the castles of Giezar and Kœningratz,
with all my orders of knighthood and nobility, and my colonel-generalship
of the Imperial Cavalry, may go to the devil for aught that I care. Ha—what
is this?"

He paused, for there was, I knew, a terrible expression in my face; and,


unable longer to conceal my emotion, I flung away my sword, muffled my
face in my plaid, and burst into tears.

CHAPTER XLVIII.

THE SUN SHINES AGAIN.

We entered the room where she lay, and the stillness of death was there.
We approached her with reverence; and when I stretched my hand towards
the veil that covered her, it was with the air of a monk displaying the
sacrament, for the remains of those we love are to us the holiest of all holy
things.

"Ernestine—oh, my Ernestine!" sobbed the count. I thought that the veil


which shrouded her figure moved.

It was but fancy.

We stood silent, for our hearts swelled with the most intense sadness,
and were filled by the memory of the past.
Language cannot portray what the count felt, for the shock was so
sudden. Within one hour his pale cheek had sunk; his eyes were inflamed,
and his voice trembled. The very profundity of the poor father's affliction
had dried up the ordinary channels of grief, and thus no tear escaped to
relieve his agony.

The face of Ernestine had still its unpleasant expression, and yet, amid
its awful stillness, I could have sworn a spasm contracted it.

The coffin was preparing; two of Spynie's soldiers were making it.

For a time the count was like a statue; frozen, impassible. I have said his
grief was of that kind which had neither tears nor words. It escaped in deep,
dry, agonizing sobs, and he clenched his nether lip with his teeth till the
blood came.

"Blessed God, thou triest me sorely! Both are gone! both gone now!—
and I am alone in this wide, dreary world again. At my age 'tis said we
cannot weep."

In brief terms, I informed the count of the relationship between us, and
how Ernestine and I had discovered at Nyekiöbing, that he was my long lost
uncle, Philip—and she my cousin. He gazed at me as if he thought I raved;
then he seemed to be convinced, and then dismissed it from his mind; for
surprise, regard, and all minor emotions, had shrunk before the tornado of
great and overwhelming grief.

"How long has she been dead?" he asked, in a low and husky voice.

"Since yesterday at noon—yesterday morning, she was alive and spoke


to me."

The tears now burst from the eyes of the old soldier, and, stooping over
the body, he embraced and kissed it.

Suddenly he uttered a cry, and turned to me with wildness and


astonishment in his eyes.
"She is warm—she lives! Ernestine! Ernestine!"

I sprang to his side, and clasped one of her hands in mine. It was quite
warm!

There was a convulsive motion in her fingers and feet; she opened her
eyes, and a faint sigh escaped her; joy and terror bewildered me for a
moment. Then I rushed away in search of a surgeon. Hurrying through the
streets bareheaded, and without sword, scarf, or doublet, the first I met was
no other than old Pennicuik. He thought me seized by delirium; but
accompanied me without delay to the room of Ernestine, who seemed to be
again hovering between life and death.

How dimly and confusedly that new day of terror, grief, and joy floats
before me! I was like one who suffered from vertigo; I do not think I had
the full use of my senses. Pennicuik immediately ordered all the windows to
be opened; he took the pillows from under her head; he bathed her temples
with Hungary water, eau de luce, and warm brandy; he spunged her little
hands and snow white arms in vinegar and warm water; and a little wine
was gently poured between her lips. Then, after the fashion of the female
nurses at the Altenburg hospital, he blew air into her lungs by the nostrils.

In two days she was so fully restored to life as to be able to relate to us


all her sensations, some of which were very remarkable.

She had dreamed that she was dead, and yet was sensible of all that
passed around her. At times it seemed as if her spirit left her body, and yet
remained near it—appearing to hover over that which it had no longer the
power to move. When I kissed her, and closed her eyes, she had felt the
touch of my hand without having the power of opening her eyes again. The
horror of being buried alive occasioned her the utmost agony; and when she
heard persons moving about her—when she heard sounds in the street,
especially the jangle of the death-cart bell, her unexpressed agitation was
terrible; but her soul could no longer act upon her fettered tongue, and she
felt icy cold. Hence those spasmodic contractions of feature which I had
actually seen, but thought were the result of my own disturbed fancy. The
approach of her father, and the sound of his voice, gave a new impulse to
her almost prostrate mind; it resumed its wonted power over her weakened
organisation, and produced the sudden warmth which had startled him,
when he thought he was embracing her for the last time.

Language has no power to describe the joy of such a restoration, as it


seemed, from the very jaws of the grave; but it formed the subject of two
sermons—one preached by Father Ignatius, and the other by the reverend
Gideon Geddes, who construed the affair very differently; for the Jesuit
affirmed that she had been restored to life by virtue of certain blessed
reliques which he had cunningly slipped below her pillow; while the
Presbyterian declared that she had merely been restored to existence, that
she might live to see the errors of popery and its ways; and if the reader
partake my joy and satisfaction, he or she will pardon my having kept them
behind the curtain for a single chapter.

Little more remains to be told.

Rendered desperate by the successive defeats he had sustained since the


battle of Lütter, Christian IV. was compelled, at the conference of Lubeck in
1629, to accede to the terms of a treaty of peace offered by the great Duke
of Friedland, who then restored to Denmark all that he and Tilly had taken
beyond the Elbe; and the siege of Gluckstadt, which had been so valiantly
defended by the Scottish cavaliers of Sir David Drummond, was raised. The
conditions imposed upon Christian were, that he should no more interfere in
the German affairs than he was entitled to do as Count of Holstein; that on
no pretext was he to enter the circles of Lower Germany; that he was to
leave the weak and timid family of the palatine to its fate; and that the
Scottish troops in his service were to quit it forthwith.

Thus, by a strange combination of misfortunes, was the most gallant of


the Danish monarchs compelled to retire ingloriously from the great arena
of the German war.

After thanking us for our services, he bade us adieu, and I saw the tears
glisten in the only eye that war had left him. He sailed—not to rejoin his
queen, who always met him with coldness in his reverses—but to seek the
society and solace of the fair Countess of Fehmarn, his wife of the left-
hand; who, whether in victory or defeat, had ever welcomed him with joy,
gratitude, and love.
Repulsed, as related, in his last attempt to obtain Stralsund by assault,
the great and ambitious Duke Albrecht, after a four months' siege, in which
he lost upwards of twelve thousand of his best and bravest soldiers, was
compelled to spike his cannon, burn his camp, destroy his baggage, and
retreat into Saxony, thus acknowledging that neither his skill nor his mighty
host had availed him before the valour of Marshal Leslie's Scottish garrison.

The plague passed away with him, and health, happiness, (and fresh
provisions,) all flowed together into Stralsund. The good and industrious
citizens resumed their wonted occupations; and, so sensible were they of
the protection our swords had afforded, that they made old Field-marshal
Leslie a magnificent present of silver-plate, and ordered medals* to be
struck in honour of the Scottish troops.

* Some of these are still (I believe) in possession of the Leven family.

It was arranged that the Highland regiment of Strathnaver, then reduced


to about four hundred men, should enter the Swedish service with Sir
Alexander Leslie, and that all the Scottish and French volunteers who
served King Christian, should accompany them; but as Ian Dhu and I had
seen enough of the German wars to enable us to acquit ourselves in Scottish
society at home; and, moreover, as a cloud was darkening in the political
horizon of the north, we took a sad farewell of the brave fellows we had led
in so many arduous encounters, and prepared to return to our native glens.
The count prepared to accompany us.

"I am now sick of war," said he; "and, as King Jamie said of old, have a
salmon-like instinct to revisit the place of my nativity."

Aware that reverses of fortune might one day come upon him, and that
his estates of Carlstein, Giezar, and Kœningratz in Bohemia, were perhaps
little better than so many castles in the air, the count, like a wary old soldier,
had gradually secured vast sums in the hands of those famous and wealthy
merchants, Thomas Watson of Leith, and Herr Dübbelsteirn of Glückstadt.
Thus he was as independent of the family at Craigrollo as I; for, on my
marriage with Ernestine (which we had arranged should take place in the
old kirk of St. Regulus at home), I would receive a handsome share of the
count's prize-money, which would form a very reputable estate, the more so
if we could secure the two baronies of poor Kœningheim; but I feared that
would be no easy matter, as various real or imaginary relations had already
possessed themselves of all his towers and places of strength.

However, we fully hoped to be able to give direct contradiction to the


old prophecy anent the family heirloom, and the absurd assertion that never
a Rollo throve in this world if his mouth was unable to receive its mighty
disc.

I shall never forget the day on which we marched from Stralsund; for we
all embarked together. My dear comrades to enter on the long and glorious
career of the new German war; Ernestine, the count, Ian, and myself, with
Phadrig Mhor, to return to old Scotland; for Ian was to be married to his
Moina, and Phadrig remembered that there was a lint-locked lassie in
Strathdee, who would be very well pleased if again he came back to her and
the green forests of Braemar.

Ernestine had fully recovered, and had become more beautiful and
radiant than ever.

She wept when honest Father Ignatius lifted up his long bony hands and
blessed her, before departing, staff in hand, as he said, "like St. Argobastus
the Scot," on his lonely pilgrimage after the Imperial host.

The Swedish fleet lay at anchor in the Sound to receive the regiment,
which my heart bled to leave.

The good ship Scottish Crown, with all her sails loose, and a spring upon
her cable, waited to receive us.

On one side lay the deserted trenches and dismantled batteries of the
discomfited Wallenstein; here lay a brass cannon with the moss upon its
muzzle; there a mound, where the fresh grass sprouted above the calm
repose of the dead, and the autumn flowers expanded in the morning
sunshine.

On the other side rose busy Stralsund, its shining walls decorated by
silken banners, and its church-bells tolling merrily; for now, war, disease,
and desolation, had passed away together.

Between, lay the blue waters of the narrow Sound, where the white sails
of the Scottish and Swedish ships were flapping in the morning wind.

By the round archway, by the stony streets, and the frowning bastions,
our hoarse drums beat merrily, and the shrill fife, with the proud war-pipe
of the Gaël, rang upon the breeze; the green tartan waved, and the silken
banners with the Red Lion and the Silver Cross rustled above our heads. All
our hearts beat high with hope and ardour; and yet it was not without a sigh
of regret for the brave Scottish hearts that had grown cold for ever beneath
Jaromar's walls, that we marched down to the crowded and sunny beach for
embarkation.

NOTES.

THE SCOTS IN DENMARK.

Some account of the Scottish troops who went to Denmark about 1625,
will be found in the "Memoirs of Sir John Hepburn," recently published by
the author of this work. They appear to have mustered as follows:—

Men.
The regiment of Sir Donald Mackay of Farr
1500
Colonel Sir James Leslie's regiment
1000
Alexander Seaton's
500
The regiment of the Earl of Nithsdale, three Batts
3000
The regiment of Alexander Lord Spynie, three Batts
3000
The regiment of Sir James Sinclair of Murkle, ditto
3000

These 12,000 men were independent of 3000 sent by Scotland to the Isle
Rhé, and about 13,000 more who entered the service of Gustavus Adolphus,
while at the same time many of the Scottish Catholics flocked to the
standard of the Emperor Ferdinand II.

THE SCOTTISH FLAG.

"The regiment received colors," says Colonel Munro, "wheron His


Majestie (Christian IV.) would have the officers to carry the Danes Crosse,
which the officers refusing, they were summoned to compeare before his
Majestie at Raynesberge, to know the reason of their refusall—and for the
eschewing of greater inconvenience, the officers desired so much time of
his Majestie, as to send Captaine Robert Ennis into England, to know his
Majestie of Great Britaine's will, whether or no they might carrie without
reproach the Danish crosse in Scottish Colors." Answer was returned, that
they should obey the orders of him they served.—See Munro's Expedition
with Machay's Regiment. Published 1637.

THE HIGHLAND PURSE.

Macnab, of Macnab, presented to the Scottish Antiquaries, in 1783, a


Highland-purse clasp, exactly similar to that described as being worn by
Philip Rollo. This suggested to Scott a similar clasp for guarding the
sporran of Rob Roy, who said to Bailie Jarvie, "I would advise no man to
attempt opening this sporran till he has my secret."

The story of the Lily of Culbleine is an ancient Scottish tradition: her


grave is still shown in her native parish; and many of the characters
mentioned in the foregoing pages were all persons who really existed at the
time. I may particularly instance Dr. Pennicuik of Newhall and that Ilk, an
account of whom will be found in the Scots Magazine for 1805. Other
names, such as Sir Alexander Leslie's, belong to the history of Scotland, and
require no comment. Bandolo is also a real character; and his double
assassinations at Naples are veritable history.

THE ROLLO SPOON.

The idea of this quaint heirloom is taken from a similar one preserved by
the ancient family of Crauford of Cowdenhill. It is of silver, measuring
three inches wide in the mouth, and inscribed—

"This spoon I leave in legacie,


To the maist mouthed Crauford after me.
1480."

MACKAY'S OFFICERS.

Some idea of the service seen by the regiment of Strathnaver, may be


gathered from the following list of its officers, who were wounded or lost
their lives in the service of Christian IV. of Denmark, between August 1626,
and August 1629. It is made up from Munro, and others.

Colonel Sir Donald Mackay, Bart., scorched by powder at the defence of


Oldenburg.

Lieutenant-Colonels Seaton, and Arthur Forbes, wounded at Oldenburg.

Major Dumbar, slain defending Boitzenburg.


Captain Boswal, slain by the boors in Bremen.

Captain John Learmonth of Balcomie, wounded twice by musket-balls at


Boitzenburg, and died in consequence at Hamburg.

Captain Sir Patrick M'Gie received a wound at Oldenburg, of which he died


at Copenhagen.

Captain John Forbes of Tulloch, wounded at Oldenburg,

Captain Robert Munro, wounded in the knee at Oldenburg.

Captain Duncan Forbes, killed at Bredenburg.

Captain Duncan Carmichael, killed at Bredenburg.

Captain Thomas Mackenzie of Kildon (Lord Seaforth's brother), wounded


in the legs at Eckernfiörde.

Captain Thomas Armis, wounded at the siege of Stralsund.

Captain Andrew Munro, also wounded there; and afterwards slain in single
combat by the Count of Rantzau, in the Isle of Fehmarn.

Captain Lieutenant Kerr, wounded in an arm at Eckernfiörde.

Lieutenant David Martin, killed at Boitzenburg.

Lieutenant Hugh Ross, lost a leg by a cannon-shot at Oldenburg.

Lieutenant Andrew Stewart (brother of John, first Earl of Traquair) received


a wound at Oldenburg, and died of it at Copenhagen.

Lieutenant Andrew Barbour, killed at Bredenburg,

Lieutenant David Munro, scorched by powder when blowing up the church


at Eckernfiörde.

Lieutenant David Beaton, wounded at Stralsund.


Lieutenant Arthur Arbuthnot, also wounded there.

Ensign Innes, wounded at Oldenburg, and slain at Stralsund.

Ensign Seaton, wounded at Oldenburg, and slain at Stralsund.

Ensign Stewart, wounded at Oldenburg.

Ensign Gordon, wounded at Oldenburg.

Ensign David Munro, wounded at Oldenburg.

Ensign Patrick Dunbar, wounded at Stralsund.

Quarter-master Bruntisfield, wounded at Stralsund, where 500 of the


Highlanders were killed.

Chaplain, killed at Bredenburg.

The regiment had more than 30 officers killed and wounded in three
years; and lost more than 1000 privates in the same short space of time.

THE END.

M'CORQUODALE AND CO., PRINTERS, LONDON—WORKS, NEWTON.


*** END OF THE PROJECT GUTENBERG EBOOK PHILIP ROLLO; OR,
THE SCOTTISH MUSKETEERS, VOL. 2 (OF 2) ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG
LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or

You might also like