Sugar v0.84: What's New for Developers


With the new version of Sugar, 0.84, we have made a lot of progress in our goal to encourage Sugar users to appropriate the technology. We do not think that our users should be satisfied to be just consumers of Sugar; we would like them to understand how Sugar works and to feel empowered to make improvements.

olpc sugar

This is why we have been working towards making it as easy as possible for them to modify Sugar such that it is better suited to their personal and collective needs.

User Modifications

There are two aspects of Sugar that are sympathetic to our goal of user modifications:

  1. it is written in Python; and
  2. it is distributed as Free Software.

Python is an interpreted programming language that is very easy to understand and modify, and being Free Software means that users have the rights to use, modify and redistribute it.

Operating under the belief that the separations between code and content and between consumer and producer are artifacts of the old software and media industries, we have been working during the last months on three areas that lower the barriers to entry for people that wish to modify Sugar. We call the removing of limits on possibilities, "removing the ceiling", and the lowering or easing of entry ramps, "lowering the floor" for computing success.

View Source key works!

View source

In previous releases, only Etoys and some simple activities such as Chat and Read had the capability of displaying their source code, letting the user drill deep into how the activity works. For 0.84, we have extended this ability to every activity. It works better for activities that are written in an interpreted language, e.g., Python, but if a compiled activity includes the source code, users will be able to "view" it and, since Sugar makes people smarter, they'll be able to understand how it works.

The authors of some activities, for example Browse and TurtleArt, provided some additional drilling capability to their activities. The users can see how their Turtle Art programs look as Logo code; curious readers can peek into the HTML code of a web page.

The author of an activity written in Python that wishes to handle all the view source by herself can override the Activity.handle_view_source method, thus replacing the standard dialog by an activity-specific implementation. And for providing an additional code representation like HTML or Logo, then Activity.get_document_path can be overridden to provide a file path to it.

For the same effects, authors of activities written in languages other than Python can implement the methods org.laptop.Activity.HandleViewSource() and org.laptop.Activity.GetDocumentPath(), as kindly documented by Bert Freudenberg here.

Extending the Sugar shell

Extending the shell was never that easy. For example you can extend the Control Panel by adding a new section, adding a new device to the Frame, or defining a new keyboard shortcut. You only need to put your Python code, following the API guidelines, at a certain place and the extension is picked up by the shell on startup automatically.

The API is unstable for the moment and will be reviewed in the next release cycle. Nevertheless, people have been writing little widgets, like a clock, for the Frame already.

Etoys to the ladybug rescue

Using Etoys, Mozilla, Abiword, and Evince in your activity

The Sugar platform provides several sets of building blocks.

One of those blocks is Etoys. It is a Squeak virtual machine on which you can base your activities on and also the Etoys environment is available to give the users of your activity an advanced interactive environment.

Embedding Mozilla into your activity will give it browser abilities, like rendering html and executing javascript. For Python activities, run 'pydoc hulahop' or check out the Browse sources. You can watch for even better integration with the web in Sugar 0.86.

Abiword offers a powerful text processing widget with advanced features like those found in word processors. It also offers collaboration that allows several users of your activity to edit a text buffer simultaneously across the network. You can base your work on Write's source code or run 'pydoc abiword'.

Evince is a document viewer that will render PDF, PostScript, and other document formats within an area of your activity's window. Python coders can check 'pydoc evince' or see Read's source code.

Don't stay watching on the side, join us today!

Both Tomeu Vizoso and Simon Schampijer are volunteer contributors with Sugar Labs

Related Entries