What is a Sugar Activity?
A Sugar Activity is a self-contained Sugar application packaged in a .xo bundle.
An .xo bundle is an archive file in the Zip format. It contains:
- A MANIFEST file listing everything in the bundle
- An activity.info file that has attributes describing the Activity as name=value pairs. These attributes include the Activity name, its version number, an identifier, and other things we will discuss when we write your first Activity.
- An icon file (in SVG format)
- Files containing translations of the text strings the Activity uses into many languages
- The program code to run the Activity
A Sugar Activity will generally have some Python code that extends a Python class called Activity. It may also make use of code written in other languages if that code is written in a way that allows it to be used from Python (this is called having Python bindings). For instance, you can use WebKit, an HTML component, as part of your Activity. This would enable you to write most of your Activity using HTML 5 instead of Python.
It is even possible to write a Sugar Activity without using Python at all, but this is beyond the scope of this book.
There are only a few things that an Activity can depend on being included with every version of Sugar. These include modules like Evince (PDF and other document viewing), WebKit (rendering web pages), and Python libraries like PyGTK and PyGame. Everything needed to run the Activity that is not supplied by Sugar must go in the bundle file. A question sometimes heard on the mailing lists is "How do I make Sugar install X the first time my Activity is run?" The answer: you don't. If you need X it needs to go in the bundle.
You can install an Activity by copying or downloading it to the Journal. You uninstall it by removing it from the Journal. There is no Install Shield to deal with, no deciding where you want the files installed, no possibility that installing a new Activity will make an already installed Activity stop working. For the child installing an Activity the process is no more difficult than installing an app on a smart phone.
An Activity generally creates and reads objects in the Journal. A first rate Activity will provide some way for the Activity to be shared by multiple users.