Week 8 Xo Specific Material And Application Deployment

Hello World Activity (Week 8)

Adapted from OLPC Wiki

The purpose of this week is to get familiarized with creating an XO activity before moving on to harder activities involving mesh networking, sound, etc.

How an Activity Is Packaged

  • .xo files have a specific package type
    • They are actually .zip files renamed
    • You can actually rename them and then unzip them
  • Major content components are as follows:
    • Your Python file (for game, utility, etc.)
    • Applicable Glade file (if you're using one, see previous weeks)
    • A .info file - defines your application's traits
    • Your application's SVG - an icon
    • A setup.py file - installs your activity to the proper place
    • A MANIFEST file - can be automatically generated, just a list of files
  • These are found in the following directory architecture:

The .info File

  • The following is the file format for the .info file:
 name = YourActivityName
 bundle_id = org.laptop.YourActivityName
 class = YourActivityName.YourActivityName
 icon = activity-youractivityname
 activity_version = 1
 host_version = 1
 show_launcher = yes
  • An explanation of each part follows:
    • name - the name you want displayed within the Sugar operating system (in the dock)
    • bundle_id - much like the bundle ID in Java, this is how other applications will refer to you
    • class - this is important, if not set up properly your activity will not run
      • The class name is created by appending the class name within your .py file to the name of your .py file
      • For our purposes, just make them the same always
    • icon - the name of the .svg icon found under the activity directory
      • See the later svg icon creation for some help
    • activity_version - the version of your current release, meant for Sugar to know when to update

Creating the setup.py File

  • setup.py is used for building and installing the activity when downloaded to an XO
    • This can include compiling the python files to .pyc files for later running, but this is done automatically with a simple call
  • For the purposes of this course, you can generally get away with the following setup.py file:
 #!/usr/bin/env python
 from sugar.activity import bundlebuilder
  • You can also perform cleanup of a previously installed activity or call other builds within the setup.py file

Generating the MANIFEST File

  • A MANIFEST file can be easily created by running the following Unix command at the root of your activity's directory
find . -type f | sed 's,^./,,g' > MANIFEST
  • This may be an interesting topic of research for the students, making use of Unix pipes in order to create the MANIFEST file

Creating an SVG

  • SVG files are vector files
  • Why did OLPC choose to use SVG files for activity icons?
    • For the same reason that OS X chooses to use a type of vector icon
    • Easily resizable, can be expanded or contracted for the dock, recolored, etc.
      • Much like in the OS X dock
    • Windows XP does not have vector icons, and when they are resized (like in an alt+tab), they don't look good
  • How do we create an svg file?
    • Inkscape is a cross platform application which can be used to create SVG files
    • Can be downloaded here
    • Simple to use, especially when creating simple shapes and lines
    • Make sure to maintain about 5-10% padding on each side of the icon to adhere to Sugar standards

Developing on the XO

  • There is no need to package these files into a .xo file whenever you want to install it within your emulator
  • Use the SSH client and the internal XO server to move files around
    • The activity folder can be placed in /home/olpc/activities

The Assignment

  • Create a Hello World activity with the following:
    • A button labeled Hello World
  • The GUI can be easily done within the Python code, but feel free to use Glad if you so please

The Solution

  • The XO Hello World bundle can be found here
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License