Make your own sugar activities

Setting Up a Sugar Development Environment

It is not currently practical to develop Activities for the XO on the XO. It's not so much that you can't do it, but that it's easier and more productive to do your development and testing on another machine running a more conventional environment. This gives you access to better tools and it also enables you to simulate collaboration between two computers running Sugar using only one computer.

Installing Linux

If you're going to develop Sugar Activities you're going to need a machine that runs Linux.  While you can write programs using Python, PyGTK, and PyGame on any operating system you're going to need Linux to make them into Sugar Activities and test them under Sugar. It is possible to write a standalone Python program in Windows and then turn over the code to another developer who runs Linux who would then make an Activity out of it. If you're just starting out in computer programming that may be an attractive option.

Installing Linux is not the test of manhood it once was. Anyone can do it. The GNOME desktop provided with Linux is very much like Windows so you'll feel right at home using it.

When you install Linux you have the option to do a dual boot, running Linux and Windows on the same computer (but not at the same time). This means you set aside a disk partition for use by Linux and when you start the computer a menu appears asking which OS you want to start up. The Linux install will even create the partition for you, and a couple of gigabytes is more than enough disk space. Sharing a computer with a Linux installation will not affect your Windows installation at all. 

Sugar Labs has been working to get Sugar included with all Linux distributions. If you already have a favorite distribution, chances are the latest version of it includes Sugar. Fedora, openSuse, Debian, and Ubuntu all include Sugar. If you already use Linux, see if Sugar is included in your distribution. If not, Fedora is what is used by the XO computer so a recent version of Fedora might be your best bet. You can download the Fedora install CD or DVD here:

It is worth pointing out that all of the other tools I'm recommending are included in every Linux distribution, and they can be installed with no more effort than checking a check box. The same tools often will run on Windows, but installing them there is more work than you would expect for Windows programs.

There is another way to install Linux which is to use a virtual machine. A virtual machine is a way to run one operating system on top of another one. The operating system being run is fooled into thinking it has the whole computer to itself. (Computer industry pundits will tell you that using virtual machines is the newest new thing out there. Old timers like me know that IBM was doing it on their mainframe computers back in the 1970's).

If you're used to Windows you might think that running Linux in a VM from Windows instead of installing Linux might be the easier option. In practice it is not. Linux running in a VM is still Linux, so you're still going to have to learn some things about Linux to do Activity development. Also, running a second OS in a VM requires a really powerful machine with gigabytes of memory. On the other hand, I did my first Sugar development using Linux on an IBM NetVista Pentium IV I bought used for a little over a hundred dollars, shipping included. It was more than adequate, and would still be adequate today.

Having said that, there are reasons to like the virtual machine approach. I have used this method to run Linux on a Macintosh.  It looks like this:

It is really fast and easy to set this up if you have a recent Mac.  The screenshot is from a Mac Mini my wife and I bought recently which has 2 gig of RAM and more disk space than we'll ever use.   All I needed to do was download the Mac OS version from, then download a Fedora image from  This image needs to be unpacked before you can use it, so get Stuffit Expander for free from the Apple Market.  Run Virtual Box, configure your unpacked image and in no time flat you have Fedora running in a window on your desktop.  You can go to Add/Remove Programs and add Sugar and your favorite development tools and you're set.

One of the neat things about Virtual Box images is you can have more than one. The Virtual Boxes website has images from Fedora 10 up to the latest, so I can have a second image running Fedora 10 to test compatibility with very old versions of Sugar that may still be in use in the field.  I once set up a machine running Fedora 10 and deliberately avoided upgrading just so I could do this kind of testing.  Now that I have the Mac Mini running Virtual Box I should be able to give that box an upgrade. Being able to run multiple versions of Linux on the same box easily is really the biggest advantage of the Virtual Box method.

Virtual Box will also run on Windows if you have a powerful enough machine.

As for the Macintosh, it should also be possible to install Fedora Linux on an Intel Macintosh as a dual boot, just like you do with Windows.  Check the Fedora website for details.

What About Using sugar-build?

Sugar-build is a script that downloads the source code for the latest version of all the Sugar modules and compiles it into a subdirectory of your home directory.  It doesn't actually install Sugar on your system.  Instead, you run it out of the directory you installed it in.  Because of the way it is built and run it doesn't interfere with the modules that make up your normal desktop. If you are developing Sugar itself, or if you are developing Activities that depend on the very latest Sugar features you'll need to run sugar-build.

Running this script is a bit more difficult than just installing the Sugar packages that come with the distribution.  You'll need to install Git, run a Git command from the terminal to download the sugar-build scripts, then do a make run which will download more code, possibly ask you to install more packages, and ultimately compile everything and run it.  When you're done you'll have an up to date test environment that you can run as an alternative to sugar-emulator.  There is no need to uninstall sugar-emulator; both can coexist.

The documentation for sugar-build will be found here:

Should you consider using it? The short answer is no. A longer answer is probably not yet.

If you want your Activities to reach the widest possible audience you don't want the latest Sugar. In fact, if you want a test environment that mimics what is on most XO computers right now you might need to use an older version of Fedora. Because updating operating systems in the field can be a major undertaking for a school many XO's will be not be running the very latest Sugar or even the one shipped with the latest Fedora for quite some time.

Strictly speaking sugar-build is just the script that downloads and compiles Sugar.  If you wanted to be correct you would say "Run the copy of sugar-runner you made with sugar-build". However, recent Linux distributions like Fedora 20 come with the Sugar environment as something you can install like any other Linux package. There needs to be a way to distinguish between running what came with your distribution and what you download and compile yourself and run out of your home directory. To refer to the second option I'll say "use sugar-build" or "run sugar-build".


We'll be doing all the code samples in Python so you'll need to have Python installed.  Python comes with every Linux distribution.  You can download installers for Windows and the Macintosh at

There are a couple of Python libraries you'll want to have as well: PyGTK and PyGame.  These come with every Linux distribution.  If you want to try them out in Windows or on the Macintosh you can get them here: 


Developers today expect their languages to be supported by an Integrated Development Environment and Python is no exception. An IDE helps to organize your work and provides text editing and a built in set of programming and debugging tools.

Eric the Python IDE 

There are two Python IDE's I have tried: Eric and Idle. Eric is the fancier of the two and I recommend it. Every Linux distribution should include it. It looks like it might work on Windows too. You can learn more about it at the Eric website:

SPE (Stani's Python Editor)

This is an IDE I discovered while writing this book.  It comes with Fedora and in addition to being a Python editor it will make UML diagrams of your code and show PyDoc for it.  Here is SPE showing a UML diagram for one of the Activities in this book:


If you're an experienced developer you might find this a useful alternative to Eric.  If you're just starting out Eric should meet your needs pretty well.

Other IDE's

There is also a commercial Python IDE called Wingware, which has a version you can use for free.  You can learn more about it at


Inkscape is a tool for creating images in SVG format. Sugar uses SVG for Activity icons and other kinds of artwork. The “XO” icon that represents each child in the Neighborhood view is an SVG file that can be modified.

Using Inkscape to create an Activity icon 

Inkscape comes with every Linux distribution, and can be installed on Windows as well. You can learn more about it here:


Git is a version control system. It stores versions of your program code in a way that makes them easy to get back. Whenever you make changes to your code you ask Git to store your code in its repository. If you need to look at an old version of that code later you can. Even better, if some problem shows up in your code you can compare your latest code to an old, working version and see exactly what lines you changed.

git11_1.jpg ⁞

If there are two people working on the same program independently a version control system will merge their changes together automatically.

Suppose you're working on a major new version of your Activity when someone finds a really embarrassing bug in the version you just released. If you use Git you don't need to tell people to live with it until the next release, which could be months away. Instead you can create a branch of the previous version and work on it alongside the version you're enhancing. In effect Git treats the old version you're fixing and the version you're improving as two separate projects.

You can learn more about Git at the Git website:

When you're ready for a Git repository for your project you can set one up here:  I will have more to say about setting up and using a Git repository later in this book.

There is a Git repository containing all the code examples from this book.  Once you have Git installed you can copy the repository to your computer with this command:

git clone git://\

This command should be typed all on one line.  The backslash (\) character at the end of the first line is used in Linux to continue a long command to a second line.  It is used here to make the command fit on the page of the printed version of this book.  When you type in the command you can leave it out and type myo-sugar-activities-examples/mainline.git immediately following

This convention of splitting long commands over multiple lines will be used throughout this book.   In addition to that, the code in Git will generally have longer lines than you'll see in the code listings in the book.  For that reason I'd recommend that you not try to type in the code from these listings, but use the code in Git instead.


The GIMP is one of the most useful and badly named programs ever developed. You can think of it as a free version of Adobe Photoshop. If you need to work with image files (other than SVG's) you need this program.

Using The GIMP to make a screen capture 

You may never need this program to develop the Activity itself, but when it's time to distribute the Activity you'll use it to create screen shots of your Activity in action. Nothing sells an Activity to a potential user like good screen shots.

Sugar Emulation

Most Linux distributions should have Sugar included. In Fedora you can run Sugar as an alternative desktop environment. When you log in to GDM Sugar appears as a desktop selection alongside GNOME, KDE, Window Maker, and any other window managers you have installed.

This is not the normal way to use Sugar for testing. The normal way uses a tool called Xephyr to run a Sugar environment in a window on your desktop. In effect, Xephyr runs an X session inside a window and Sugar runs in that. You can easily take screen shots of Sugar in action, stop and restart Sugar sessions without restarting the computer, and run multiple copies of Sugar to test collaboration.

sugar-emulator in action 

I'll have more to say about this when it's time to test your first Activity.