User:PIOLPCIntern-1/docs

From OLPC
< User:PIOLPCIntern-1
Revision as of 17:59, 3 August 2007 by PIOLPCIntern-1 (talk | contribs) (New page: __toc__ ==Creating Activities with Python code== asic Activity Creation for JHBuild w/ python. note: This is merely a compilation of the various descriptions of activity creation of the...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Creating Activities with Python code

asic Activity Creation for JHBuild w/ python.

note: This is merely a compilation of the various descriptions of activity creation of the olpc wiki (wiki.laptop.org) combined with my experience trying to create a working activity. Sometimes the descriptions are completely copied, some paraphrased, and some are all me.


1. Create a directory called 'activityname-activity' in the sugar-jhbuild/source folder, where 'activityname' is the name of your activity (ie, read, browse). The '-activity' is a naming convention.

2. Within that directory, create another called 'activity'

3. In the activity directory, create a new file called 'activity.info'. This file should have the following in it (lines beginning with # are my comments):

[Activity]

  1. This top line should not change; it should always read [Activity].

name = NameOfActivity

  1. This is the name of the activity as it will appear in Sugar.

service_name = com.Activity.Example

  1. This is the activity's dbus service name. It is required. It is also used
  2. as the activity's default service type when the activity is shared on the
  3. network. To determine this type, the distince parts (separated by the '.'
  4. character) are reversed, any '.' is replaced by a '_' character, and the
  5. type is prefixed by a '_' character. So in this example, the default
  6. service type would be "_Example_Activity_com".

class = myactivity.ActivityClass

  1. This is the location of the main class of the program, where 'myactivity' is the python file with the class in it, and
  2. 'ActivityClass is the name of the class.

icon = icon

  1. The name of the icon image file.

activity_version = 1

  1. The version of the activity.

show_launcher = yes

  1. Whether or not to show the icon in the sugar launcher.

4. Put the image (in .svg format) to be used as the activity's icon in the activity folder.

5. Go back to the activityname-activity directory.

6. In this directory, place the your python code files. Create the following blank files: 'setup.py', 'NEWS', and 'MANIFEST'

7. Open MANIFEST in a text editor, and type in a list of files to include in the package. (myactivity.py, for example.)

8. Edit the setup.py file to read:

  1. !/usr/bin/env python

from sugar.activity import bundlebuilder if __name__ == "__main__":

   bundlebuilder.start("MyActivityName")

where 'MyActivityName' is the name of the activity. I don't really know where this name shows up; I created an activity with this name different from all the other ones I used and didn't see it anywhere. Maybe it's what it calls the .xo when you create an activity bundle?

9. In the terminal, run ./sugar-jhbuild shell

10. cd to the activityname-activity folder and run 'python ./setup.py dev'

11. The activity should now show up in Sugar. To create an activity bundle instead of installing it to sugar, run 'python ./setup.py dist'