[Ebooks PDF] download Kivy : interactive applications and games in Python : create responsive cross-platform UI/UX applications and games in Python using the open source Kivy library Second Edition Roberto Ulloa full chapters
[Ebooks PDF] download Kivy : interactive applications and games in Python : create responsive cross-platform UI/UX applications and games in Python using the open source Kivy library Second Edition Roberto Ulloa full chapters
com
https://textbookfull.com/product/coding-games-in-python-1st-edition-
carol-vorderman/
textbookfull.com
https://textbookfull.com/product/create-gui-applications-with-python-
qt5-pyside2-edition-martin-fitzpatrick/
textbookfull.com
https://textbookfull.com/product/law-in-american-history-
volume-2-from-reconstruction-through-the-1920s-1st-edition-white/
textbookfull.com
Design User Experience and Usability Designing Pleasurable
Experiences 6th International Conference DUXU 2017 Held as
Part of HCI International 2017 Vancouver BC Canada July 9
14 2017 Proceedings Part II 1st Edition Aaron Marcus
https://textbookfull.com/product/design-user-experience-and-usability-
designing-pleasurable-experiences-6th-international-conference-
duxu-2017-held-as-part-of-hci-international-2017-vancouver-bc-canada-
july-9-14-2017-proceedings-part/
textbookfull.com
https://textbookfull.com/product/laws-of-ux-using-psychology-to-
design-better-products-services-1st-edition-jon-yablonski/
textbookfull.com
Chemistry 7th Edition John E. Mcmurry
https://textbookfull.com/product/chemistry-7th-edition-john-e-mcmurry/
textbookfull.com
[1]
Kivy – Interactive Applications
and Games in Python
Second Edition
Roberto Ulloa
BIRMINGHAM - MUMBAI
Kivy – Interactive Applications and Games in Python
Second Edition
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78528-692-6
www.packtpub.com
Credits
Reviewers Proofreader
Takumi Adachi Safis Editing
Philip Bjorge
Joe Dorocak Indexer
Priya Sane
Vijay Mahrra
Edward C. Delaporte V
Graphics
Sheetal Aute
Commissioning Editor
Disha Haria
Nadeem N. Bagban
Jason Monteiro
Acquisition Editor
Nikhil Karkal Production Coordinator
Nitesh Thakur
Technical Editor
Ankur Ghiye
Copy Editor
Adithi Shetty
About the Author
Philip Bjorge is a full-stack developer who has worked on projects for health,
amusement parks, academics, and high-tech industries. Prior to joining Substantial,
a Seattle-based software design agency, he worked on the Xbox Music and Video
team at Microsoft. Most notably, he was a developer for Surface Music Kit, an app
that was featured at the Surface 2 press conference unveiling and was on display in
Microsoft stores nationwide.
Joe Dorocak, whose Internet moniker is Joe Codeswell, is a very experienced
programmer. He enjoys creating readable code that implements project requirements
efficiently and in a manner that can be easily understood. He considers writing code
akin to writing poetry. He crafts his code so it acts as communication, not only with
the machine platforms on which it runs, but also with the human programmers who
will read it in the future.
Joe has been employed directly and also in a contractual role by start-ups and by
many major top-shelf companies, including IBM, HP, and GTE/Sprint.
Joe has also worked on Kivy Blueprints by Mark Vasilko and Functional Programming
in JavaScript by Dan Mantyla.
Edward C. Delaporte V has been creating and using software since the
mid 1980s.
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
TM
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser
[i]
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Table of Contents
[ ii ]
Preface
Mobile devices have transformed the way applications are perceived. They
have increased in interaction types; the user now expects gestures, multi-touches,
animations, responsiveness, virtual keyboards, and magic-pens. Moreover,
compatibility has become a must if you want to avoid the barriers imposed by
major operating systems. Kivy is an open source Python solution that covers these
market needs with an easy-to-learn and rapid development approach. Kivy continues
to grow fast and two versions have been released since the first publication of this
book in September 2013. Thanks to an enthusiastic community, Kivy is making its way
in an extremely competitive territory in which it stands out for offering both a cross-
platform and efficient alternative to native development and HTML5.
This book introduces you to the Kivy world, covering a large variety of important
topics related to interactive applications and games development. The components
presented in this book were selected according to their usefulness for developing
state-of-art applications and also for serving as an example of broader Kivy
functionalities. Following this approach, the book covers a big part of the
Kivy library.
This book provides you with examples to understand their use and how to
integrate the three projects that come with this book. The first one, the comic
creator, exemplifies how to build a user interface (Chapter 1, GUI Basics – Building
an Interface), how to draw vector shapes in the screen (Chapter 2, Graphics – the
Canvas), how to bind user interactions with pieces codes (Chapter 3, Widget Events
– Binding Actions), and other components related to improving the user experience
(Chapter 4, Improving the User Experience). The second project, Invaders Revenge, is an
interactive game that introduces you to the use of animations, scheduling of tasks,
keyboard events, and multi-touch control (Chapter 5, Invaders Revenge – an Interactive
Multi-touch Game). The third project, Kivy Player, teaches how we can control video
streams with a modern design and responsive interactions to maximize the use of the
screen (Chapter 6, Kivy Player – a TED Video Streamer).
[ iii ]
Preface
Occasionally, this book explains some technical but important Kivy concepts that are
related to the Kivy class structure and implementation, or the order and strategies to
draw on the screen. These explanations give the reader some insights into the Kivy
internals that will help them solve potential problems when they develop their own
projects. Even though they are not necessary for the comprehension of the main
topics of this book, they will become important lessons when the reader faces new
situations implementing their own applications.
This book grabs the reader's attention by stating interesting programming scenarios.
The sections are generally short and straightforward, making the learning process
constant. These short sections will also serve as a reference when the reader finishes
the book. However, serving as a reference doesn't prevent the text from achieving the
main goal, which is teaching bigger projects that connect the small topics. At the end
of this book, the reader will feel comfortable to start their own project.
Chapter 2, Graphics – the Canvas, explains the use of the canvas and how to draw
vector figures on the screen.
Chapter 3, Widget Events – Binding Actions, teaches how to connect the interactions of
the user through the interface with particular code inside the program.
[ iv ]
Preface
Conventions
In this book, you will find a number of text styles that distinguish between different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"This is the reason we included the on_touch_down event."
[v]
Preface
New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "We need
an alternate way to stop the video (different from the Stop button)."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it helps
us develop titles that you will really get the most out of.
[ vi ]
Preface
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
[ vii ]
Preface
We appreciate your help in protecting our authors and our ability to bring
you valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
[email protected], and we will do our best to address the problem.
[ viii ]
GUI Basics – Building an
Interface
Kivy is a free, open source Python library that allows for quick and easy
development of highly interactive multiplatform applications. Kivy's execution
speed is comparable to the native mobile alternative, Java for Android or Objective
C for iOS. Moreover, Kivy has the huge advantage of being able to run on multiple
platforms, just as HTML5 does; in which case, Kivy performs better because it
doesn't rely on a heavy browser, and many of its components are implemented
in C using the Cython library in such a way that most of the graphics processing
runs directly in the GPU. Kivy strikes a great balance between performance and
portability across various hardware and software environments. Kivy emerges with
a simple but ambitious goal in mind:
"… same code for every platform, at least what we use every day: Linux/Windows/
Mac OS X/Android/iOS"
This support has being extended to Raspberry Pi, thanks to a crowd funding
campaign started by Mathieu Virbel, the creator of Kivy. Kivy was introduced
for the first time at EuroPython 2011 as a Python framework designed for creating
natural user interfaces. Since then, it has grown bigger and attracted an enthusiastic
community.
[1]
GUI Basics – Building an Interface
This book requires some knowledge of Python, and very basic terminal skills, but
also it requires some understanding of Object-Oriented Programming (OOP)
concepts. In particular, it is assumed that you understand the concept of inheritance
and the difference between instances and classes. Refer to the following table to
review some of these concepts:
Concept URL
OOP http://en.wikipedia.org/wiki/Object-oriented_
programming
Inheritance http://en.wikipedia.org/wiki/Inheritance_(object-
oriented_programming)
Instance http://en.wikipedia.org/wiki/Instance_(computer_
science)
Class http://en.wikipedia.org/wiki/Class_(computer_
science)
Before we start, you will need to install Kivy. The installation process for all different
platforms is documented and regularly updated on the Kivy website: http://kivy.
org/docs/installation/installation.html.
All code in this book has been tested with Kivy 1.9.0 and both
Python 2.7 and Python 3.4 (but 3.3 should work fine as well).
Note that packaging support for mobile is not yet complete
for Python 3.3+. For now, if we want to create mobile apps for
Android or iOS, we should use Python 2.7. If you want to know
your Python version, you can execute python -V in a terminal
to check your installed Python version.
In this chapter, we start by creating user interfaces using one of Kivy's most fun
and powerful components – the Kivy language (.kv). The Kivy Language separates
logic from presentation in order to keep an easy and intuitive code; it also links
components at an interface level. In future chapters, you will also learn how to build
and modify interfaces dynamically using pure Python code and Kivy as a library.
[2]
Chapter 1
Here is a list of all the skills that you are about to learn:
This chapter covers all the basics for building a Graphical User Interface (GUI)
in Kivy. First, we will learn techniques to run an application and how to use and
integrate widgets. After that, we will introduce the main project of the book, the
Comic Creator, and program the main structure of the GUI that we will continue
using in the following two chapters. At the end of this chapter, you will be able to
build a GUI starting from a pencil and paper sketch, and also learn some techniques
to make the GUI responsive to the size of the window.
[3]
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
GUI Basics – Building an Interface
In order to run the code, you open a terminal (line of commands or console)
and specify the following command in Windows or Linux: python hello.py
--size=150x100 (--size is a parameter to specify the screen size).
On a Mac, you must type in kivy instead of python after installing Kivy.app in /
Applications. Lines 2 and 3 verify that we have the appropriate version of Kivy
installed on our computer.
We omit the call to kivy.require in most of the examples in the book, but you will
find it in the code that you download online (https://www.packtpub.com/), and its
use is strongly encouraged in real-life projects. The program uses two classes from
the Kivy library (lines 5 and 6) – App and Label. The class App is the starting point of
any Kivy application. Consider App as the empty window where we will add other
Kivy components.
[4]
Chapter 1
We use the App class through inheritance; the App class becomes the base class of the
HelloApp subclass or child class (line 8). In practice, this means that the HelloApp
class has all the variables and methods of App, plus whatever we define in the body
(lines 9 and 10) of the HelloApp class. Most importantly, App is the starting point of
any Kivy application. We can see that line 13 creates an instance of HelloApp and
runs it.
Now the HelloApp class's body just overrides one of the existing App class's methods,
the build(self) method. This method has to return the window content. In our
case, a Label that holds the text Hello World! (line 10). A Label is a widget that
allows you to display some text on the screen.
The following screenshot shows the resulting screen after executing the
hello.py code:
So, is Kivy just another library for Python? Well, yes. But as part of the library, Kivy
offers its own language in order to separate the logic from the presentation and to
link elements of the interface. Moreover, remember that this library will allow you to
port your applications to many platforms.
Let's start to explore the Kivy language. We will separate the previous Python code
into two files, one for the presentation (interface), and another for the logic. The first
file includes the Python lines:
14. # File name: hello2.py
15. from kivy.app import App
16. from kivy.uix.button import Label
17.
18. class Hello2App(App):
[5]
GUI Basics – Building an Interface
The hello2.py code is very similar to hello.py. The difference is that the method
build(self) doesn't have the Hello World! message. Instead, the message has been
moved to the text property in the Kivy language file (hello2.kv).
The following is the code (rules) of hello2.kv, which shows how we modify the
Label content with the text property (line 27):
You might wonder how Python or Kivy knows that these two files (hello2.py and
hello2.kv) are related. This tends to be confusing at the beginning. The key is in the
name of the subclass of App, which in this case is HelloApp.
The beginning part of the App class's subclass name must coincide
with the name of the Kivy file. For example, if the definition of the
class is class FooApp(App), then the name of the file has to be
foo.kv and in the same directory of the main file (the one that
executes the run() method of App).
Once that consideration is included, this example can be run in the same way we
ran the previous one. We just need to be sure we are calling the main file – python
hello2.py -–size=150x100.
This is our first contact with the Kivy language, so we should have an in-depth
look at it. Line 25 (hello2.kv) tells Python the minimal version of Kivy that should
be used. It does the same thing as the previous lines 2 and 3 do in hello.py. The
instructions that start with #: in the header of a Kivy language are called directives.
We will also be omitting the version directive throughout the rest of this book, but
remember to include it in your own projects.
[6]
Chapter 1
The <Label>: rule (line 26) indicates that we are going to modify the Label class.
Inside the rule, we set the text property with 'Hello World!' (line 27). The code
in this section will generate the same output screen as before. In general, everything
in Kivy can be done using pure Python and importing the necessary classes from
the Kivy library, as we did in the first example (hello.py). However, there are
many advantages of using the Kivy language and therefore this book explains all
the presentation programming in the Kivy language, unless we need to add
dynamic components, in which case using Kivy as a traditional Python library is
more appropriate.
If you are an experienced programmer, you might have worried that modifying
the Label class affects all the instances we could potentially create from Label,
and therefore they will all contain the same Hello World text. That is true, and
we are going to study a better approach to doing this in the following section.
We are going to learn the basics of how to create our own personalized widget
without affecting the default configuration of Kivy widgets. In order to do that,
we will use inheritance to create the MyWidget class in the widgets.py file:
28.# File name: widgets.py
29. from kivy.app import App
30. from kivy.uix.widget import Widget
31.
32. class MyWidget(Widget):
33. pass
34.
35. class WidgetsApp(App):
[7]
GUI Basics – Building an Interface
In line 32, we inherit from the base class Widget and create the subclass MyWidget.
It is a general practice to create your own Widget for your applications instead of
using the Kivy classes directly, because we want to avoid applying our changes to
all future instances of the widget Kivy class. In the case of our previous example
(hello2.kv), modifying the Label class (line 26) would affect all of its future
instances. In line 37, we instantiated MyWidget instead of Label directly (as we did
in hello2.py), so we can now distinguish between our widget (MyWidget) and the
Kivy widget (Widget). The rest of the code is analogous to what we covered before.
Note that now we are using buttons instead of labels. Most of the basic widgets
in Kivy work in similar ways. In fact, Button is just a subclass of Label that
incorporates more properties such as background color.
[8]
Random documents with unrelated
content Scribd suggests to you:
»Voi, veli Jegor, tyttö annettiin isä Stefanin käskystä hakea
luostariin, mutta kun noutajat tulivat hänen kanssaan veneellä alas
jokea, kaasi tyttö tuossa koskessa veneen ja kaikki muut hukkuivat
paitsi yksi veli!»
»Onko se totta?»
»Jo toinen mies tänä yönä, ja pian tulee vielä lisää!»,— sanoi
Jorma itselleen, työnsi munkin veneen virran mukaan ja hyppäsi
siihen, lähtien soutamaan Kuhasaloa kohti.
Ja mitä Jorma oli sinä yönä tehnyt Kuhasalossa, siitä nähtiin jäljet
vasta muutamien päivien kuluttua, kun karjalaisetkin menivät sinne
tekemään viimeistä tiliään. Heidän edellään oli jo ehtinyt kuolema
kulkea, sillä luostarin pihalla oli pari ruumista, eteisessä oli neljä,
vieläpä pari itse kirkossakin. Ketään eläviä ei ollut enää näkyvillä, ja
karjalaiset uskoivat jonkun luostarin omista pahoista hengistä
tehneen sen kaiken. Kirkossakin oli kaikki särjetty, ikonostaasi oli
yhtenä lautakasana lattialla ja kaikki kuvat murskana. Mutta kukaan
ei tiennyt sitä, että se sama pahahenki, joka tuon kaiken oli tehnyt,
oli itse aikoinaan toivonut pääsevänsä koko luostarin kohottajaksi ja
suurentamaksi, mutta olikin nyt tullut sen hävittäjäksi. Tämä mies oli
raivonnut luostarissa ja surmannut jokaisen, joka sattui olemaan
silloin sisällä. Ja ne, jotka olivat naaraamassa hukkuneita tovereitaan
koskesta, kiittivät hyvää onneaan, kun pelastuivat Jorman käsistä ja
pääsivät ehyin nahoin pakenemaan Valamoon. Vaikka eiväthän
sentään kaikki päässeet Valamoonkaan, sillä pitkien aikojen kuluttua
löysivät ihmiset vielä kosken läheltä kolme ruumista ja niiden viereltä
verisen seipään, jolla miesten päät oli halkaistu.
»Kunpa voisin tulla yhtä hyväksi kuin tuo suuri kuusi tuossa»,
ajatteli hän, »kunpa voisin seisoa sen tavoin kesät ja talvet, nähdä
ympärilläni kaiken kauneuden, tuntematta ikävää mihinkään. Ja kun
aikani olisi täysi, kuivuisin sitten ja kaatuisin tuohon rinteelle,
tuntematta mitään tuskaa jättäessäni elämän!»
Ei, sitä hän ei tehnyt! Sillä jos yksikään ihminen olisi tullut
valloittelemaan saareen tai häiritsemään rauhaa, olisi hän heti
pitänyt niitä vihollisinaan.
Ehken oli, ehken ei. Joka tapauksessa hän oli nyt kuin uudestaan
maailmaan palannut ja vapautunut jostakin kuoresta, joka oli tähän
saakka ympäröinyt häntä.
Kauan aikaa hän seisoi siinä katsellen, tietämättä oikein, mitä olisi
pitänyt ajatella. Jorma oli luullut pelastaneensa Pohjois-Karjalan
novgorodilaisista, mutta niitä oli tietysti tullutkin sata jokaisen hänen
tappamansa tilalle, koskapa niille ei ollut tilaa enää Kuhasalossa,
vaan piti jo tänne, keskelle karjalaiskylää, rakentaa toinen
samanlainen. Olipa ollut onni, että hän oli tullut Joutseniseen ja
säästynyt siten näkemästä niitä ristinpalvelijoita eikä tarvinnut ruveta
enää uusiin veritöihin päästäkseen heistä eroon. Mutta hiipipä jo
erakkoon pelkokin:
»Jos ne koirat tulevat tänne saareen, niin mitä minä silloin teen?»
Lieköhän ollut taas entinen Jorma, joka oli noussut samalla kertaa
järjen kanssa ja pani vastaamaan:
»Jos yksikään munkki tulee tänne, niin minä tapan sen armotta!»
Mutta nyt! Nyt kuului kuin suuri kello olisi soinut! Sen ääni kuului
aivan selvästi yli veden. — Siis sittenkin luostari! — Jorma tunsi kuin
jotakin olisi revitty rikki hänen sisällään, aivan kuin vahva käsi olisi
tarttunut sydämeen, koettaen vetää sitä ulos ruumiista. Kyllä,
varmasti siellä soi kello, vaikka erakko toivoikin vain erehtyneensä.
Ja niittyjen poikki näytti kulkevan ihmisparvia tuota uutta rakennusta
kohti. Kaikki oli aivankuin Iljan ja Teofiluksen aikoihin; silloinhan
karjalaisetkin olivat saaneet käydä kuulemassa messua luostarissa,
muttei koskaan sen jälkeen. Kenties nytkin oli tullut joku uusi Ilja
karjalaisia kastamaan?
Jorma muisti, että juuri hänestähän oli pitänyt tulla Iljan seuraaja
ja työn jatkaja. Ja olihan Ilja itsekin toivonut samaa. Mutta nyt hän
olikin täällä vain erakkona ja sai tyytyä katselemaan veden yli,
kuinka ihmiset suurissa parvissa menivät sen toisen miehen luo, joka
oli saanut hänen työnsä käsiinsä. Ja pari kolme kyyneltäkin taisi jo
tipahtaa harmaalle parralle sitä ajatellessa. Mutta hän kavahti
pystyyn ja huusi:
»Tuo on enne! Enpä ole vielä nähnyt käärmeitä täällä, mutta nyt
tuli jo ensimmäinen luostarin mukana!»
Ja kun Jorma meni majaansa, löysi hän sen pöydältä taas leipää,
voita ja lihaa. Ja aivoissa selvisi, etteivät haltiat olleet noita
hyvyyksiä koskaan tuoneetkaan, vaan ihmiset, ne tihulaiset! Vanhus
koppasi leivät pöydältä, aikoen heittää menemään, mutta tuli
kuitenkin ajatelleeksi, ettei hyviä antimia sillä tavoin saanut viskellä,
vaikka ne olivatkin ihmisten tuomia.
»Kunpa tuolla uunin takana olisi edes sirkka, joka pitäisi sirinällään
minut sen verran valveilla, etten tarvitsisi kuulla tuota helvetillistä
elämää! Mutta eivätpä näy sirkatkaan kotiutuneen murhamiehen
majaan.»
Jorma kuunteli vielä hetkisen, mutta kun ulkoa kuului vain tuulen
kohina, vaipui hän takaisin kivivuoteelleen. Mutta heti, kun hän oli
vain ummistanut silmänsä ja saanut ajatukset pois nykyisyydestä,
alkoi sama melu uudestaan. Ulkoa kuului, kuinka uhrikuusi kaatui
rymisten. Se tuntui tulevan suoraan majan päälle, mutta mätkähtikin
sitten sivuun. Itse Jumala tuntui kulkevan kuin kova tuuli sivuitse,
seinätkin ratisivat ilmavirrasta ja kaukaa kuului vaskikellon kalkatus.
Siihen liittyi toinen samanlainen, kolmas, ja niiden mukana kuului
puiden hakkaaminen mäeltä. Ja kun nuo äänet katosivat, kuului
Marjatan ääni hyvin kaukaa:
Ei, tätä ei erakko jaksanut enää kestää! Hän nousi taas istualleen,
ja samalla hetkellä hävisivät äänetkin ulkoa.
»Ei ole tullut vielä aikasi, Ontron poika, kärsi vain ja odota!»
»Miksi minun sitten pitää kärsiä enemmän kuin muiden ihmisten?
Miksen saa kuolla rauhassa minäkin? Päästäkää minut, vanha mies,
menemään jo rauhaani! Jumalat, haltiat, ketkä meitä ihmisiä
seurannettekin, älkää antako minun kuolla niinkuin murhaajan,
enhän teoillani ole tahtonut muuta kuin vapauttaa toiset ihmiset
orjuudesta!»
»Jos olen tehnyt väärin, niin minä kadun. Mutta sanokaa, mistä
minä löydän rauhani? Sanokaa, mikä se on, jota minun pitää
palvella!»
Kun Jorma katsoi nyt majansa ovelta ulos, olivat kärsineet kasvot
käyneet yhden ainoan yön kuluessa paljon entistään uurteisemmiksi.
Palo silmistä oli kadonnut kokonaan ja tilalle oli tullut jokin kaiken
läpi katsova ilme. Nyt eivät kummitelleet mielessä enää haltiat ja
kellonsoitot, vaan ajatukset kulkivat katseen mukana järvenselälle,
sinisille vaaroille, jokaiseen puuhun, pensaaseen ja laineeseen. Ja
nyt ne kaikki näyttivät taas aivan yhtä kauniilta kuin joskus, kauan
sitten seisoessa Kuhasalon rannalla katselemassa sen ympäristöä.
Silloin oli kaikki näyttänyt niin erikoiselta vain sentähden, kun hän oli
munkiksi vihkimisensä jälkeen tahtonut sanoa kaikelle sille hyvästit
siirtyessään yksinäisyyteen. Ja tällä kertaa se näytti aivan
samanlaiselta, — olihan nytkin otettava hyvästit, mutta ei siirtyessä
vapaaehtoiseen vankeuteen, vaan vapauteen, jota hän ei enää
koskaan tulisi menettämään. Jorma tiesi nyt jo kärsineensä tarpeeksi
ja pääsevänsä jonnekin sinne, mistä hän saisi paremman palkan kuin
ihmisten ihailun, kiitokset ja kyynelet.
Jorman ääni kuului siltä kuin hän olisi puhunut kuolleelle ja kuullut
vainajan kyselevän itseään.
Ja Jorma sanoi:
»En ole kuollut, vaan sinua olen etsinyt. Sentähden juuri olen
tahtonut elääkin, löytääkseni sinut tai sinun hautasi. Ja nyt on siis
pitkä matkani viimeinkin loppunut, ja minä pääsen lepäämään!»
»Niin, sen jälkeen, kun sinä jäit luostariin, menimme äidin kanssa
ensin Koitereelle, myimme siellä talon, menimme sitten Käkisalmeen
ja Viipuriin. Kun äiti kuoli, läksin minä etsimään sinua, Jorma.»
»Emme ole asuneet siellä koskaan! Mitä sinä nyt puhut? Eikö
muistisi ole enää hyvä?»