Getting started in Activity development
If you have no experience developing Sugar activities, these resources will help get you started.
Setting up a Sugar environment
If you use Linux, your best bet is to install sugar-jhbuild. You will be able to develop in your native environment, treating Sugar as just another desktop application.
To develop efficiently using an emulator or a secondary machine running Sugar natively (such as an OLPC XO), find an editor which supports editing files over a SFTP connection. Komodo Edit is a good example.
Python Reference & Tutorials
- PLEAC - Programming Language Examples Alike Cookbook
Python is the language Sugar is written in and is also used by most activities. If you don't already know Python well, you should familiarize yourself with it before continuing.
PyGTK Reference & Tutorials
PyGTK is the user interface toolkit used by Sugar activities. Bookmark these two links as you will reference them frequently during development.
The following sections of the PyGTK tutorial are most relevant to activity development.
- 1. Introduction
- 2. Getting Started
- 3. Moving On
- 4. Packing Widgets
- 5. Widget Overview
- 6. The Button Widget
- 7. Adjustments
- 8. Range Widgets
- 9. Miscellaneous Widgets
- 10. Container Widgets
- 12. Drawing Area
The Sugar Almanac contains all the information you need to start writing Sugar activities, ranging from directory structure to bundle format to API reference. It also contains answers to common questions and examples of common tasks.
This automatically updated site contains the official API documentation for Sugar. Though it is currently quite sparse, the source code is included with the documentation and it's useful to have that at your fingertips.
Cairo is the graphics library used in Sugar. The tutorial is a good introduction to the API as well as vector graphics programming in general.
Sugar Human Interface Guidelines (HIG)
Required reading before planning the user interface for your activity. These pages give a good introduction to the thought process behind the Sugar environment and will help a lot when designing your activity.
i18n (Localisation) Best Practices
Once you have strings in your Activity, here are some general tips which will make your translators happy :-)
JSON is a data format commonly used to store activity data in the Journal.
Currently, the recommended JSON library is simplejson. It has also become the standard JSON library in Python 2.6+.
NOTE: There is an odd thing about simplejson - in python25 it lives in simplejson module, but in python26 it uses json module. So, use something like this to wrap it.
Git is the version control software used by Sugar Labs. It is a distributed version control system and is quite powerful, but requires a lot of command line use.
There are dozens Python classes to satisfy the XML standard, but if you want just save/load parameters use "Zen of XML" in Python - ElementTree library. It's supported out of the box in Python 2.5 (xml.etree.ElementTree module). In previous versions you'll have to install library by yourself.
But if you just need a simple configuration format to read/write Python objects, check out JSON instead.
If you want to add a speech synthesizer for English and other languages, try the gst-plugins-espeak plugin for gstreamer.
Activity Development Resources
This is an open area for posting links related to activity development.
- http://docs.python.org/ The official Python documentation.
- http://www.pygtk.org/docs/pygtk/index.html PyGTK API reference
- http://www.pygtk.org/docs/pygobject/index.html PyGObject API reference. Contains a few important things missing from the PyGTK API such as timers and idle callbacks.
- http://api.sugarlabs.org/ The official Sugar API documentation (quite sparse but includes all the source code).
- Development Team/Almanac Detailed Sugar API overview. Quite in depth and offers answers to common questions.
- http://pygstdocs.berlios.de/ Python GStreamer bindings.
- Human Interface Guidelines The design behind the Sugar interface. Very important to read and understand before planning your activity's user interface.
- http://cairographics.org/documentation/pycairo/ Cairo Python API reference. Very sparse, use the tutorial instead.
- OLPC:Low-level Activity API Information on how activities interact with Sugar.
Tutorials and Whitepapers
- http://diveintopython.org/ An online book which teaches Python step by step.
- http://www.pygtk.org/pygtk2tutorial/index.html A very informative step-by-step introduction to PyGTK.
- http://www.olpcaustria.org/mediawiki/index.php/Activity_handbook Introduction to activity development by OLPC Austria.
- OLPC:Sugar Activity Tutorial Another introduction to activity development.
- http://www.tortall.net/mu/wiki/CairoTutorial A great introduction to Cairo in PyGTK and vector graphics drawing in general.
- http://www.json.org/fatfree.html An overview of the JSON data format.
- http://simplejson.googlecode.com/svn/tags/simplejson-2.0.8/docs/index.html Documentation for the recommended JSON library.
- OLPC:Shared Sugar Activities High level overview of collaboration.
- OLPC:Collaboration Tutorial Step by step tutorial on integrating collaboration into an activity.
- Activity_Team/Modifing_an_Activity Information describing simple modifications that can be made to common Sugar activities.
- Activity Team/Compatibility Tips Information on ensuring your activity is portable to the various distributions that run Sugar.
- http://dev.sugarlabs.org/ Bug tracking for Sugar and activities. Go here to report bugs in the Sugar toolkit. Each activity should have its own component here.
- http://git.sugarlabs.org/ Gitorious source code hosting.
- http://git.sugarlabs.org/events.atom RSS feed of all Sugar development activity. Great for keeping an eye on the project as a whole.
If you have a question, don't hesitate to ask the activity team. We are happy to help and can often save you a lot of hunting for answers.
We hang out in #sugar on irc.freenode.net, and you can always subscribe and post questions to email@example.com.