Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/app/static/doc/myosa/ch007_creating-your-first-activity.xhtml
blob: 84c414cf273c9a6996553e0fd5e1825d552ea726 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><body><h1>Creating your First Sugar Activity
</h1>
<h2 class="western">Make A Standalone Python Program First
</h2>
<p class="western">The best advice I could give a beginning Activity developer is to make a version of your Activity that can run on its own, outside of the Sugar environment. Testing and debugging a Python program that stands alone is faster, easier and less tedious than doing the same thing with a similar Activity. You'll understand why when you start testing your first Activity.
</p>
<p class="western">The more bugs you find before you turn your code into an Activity the better. In fact, it's a good idea to keep a standalone version of your program around even after you have the Activity version well underway. I used my standalone version of <strong>Read Etexts</strong> to develop the text to speech with highlighting feature. This saved me a <em>lot</em> of time, which was especially important because I was figuring things out as I went.
</p>
<p>Our first project will be a version of the Read Etexts Activity I wrote.
  <br/></p>
<h2 class="western">Inherit From The sugar.activity.Activity Class
</h2>
<p>Next we're going to take our standalone Python program and make an Activity out of it.&#160; To do this we need to understand the concept of <em>inheritance</em>.&#160; In everyday speech inheritance means getting something from your parents that you didn't work for.&#160; A king will take his son to a castle window and say, "Someday, lad, this will all be yours!"&#160; That's inheritance.
</p> In the world of computers programs can have parents and inherit things from them.&#160; Instead of inheriting property, they inherit code. There is a piece of Python code called sugar.activity.Activity that's the best parent an Activity could hope to have, and we're going to convince it to adopt our program.&#160; This doesn't mean that our program will never have to work again,&#160; but it won't have to work as much.
<br/><h2>Package The Activity
</h2>
<p>Now we have to package up our code to make it something that can be run under Sugar and distributed as an .xo file.&#160; This involves setting up a MANIFEST, activity.info, setup.py, and creating a suitable icon with Inkscape.
</p>
<div class="objavi-forcebreak">
</div>
<h2>Add Refinements
</h2>
<p>Every Activity will have the basic Activity toolbar. For most Activities this will not be enough, so we'll need to create some custom toolbars as well. Then we need to hook them up to the rest of the Activity code so that what happens to the toolbar triggers actions in the Activity and what happens outside the toolbar is reflected in the state of the toolbar.
</p>
<p>In addition to toolbars we'll look at some other ways to spiff up your Activity.
  <br/></p>
<h2> Put The Project Code In Version Control
  <br/></h2>
<p>By this time we'll have enough code written that it's worth protecting and sharing with the world.&#160; To do that we need to create a Git repository and add our code to it.&#160; We'll also go over the basics of using Git.
  <br/></p>
<h2> Going International With Pootle
</h2>
<p>Now that our code is in Git we can request help from our first collaborator: the Pootle translation system.&#160; With a little setup work we can get volunteers to make translated versions of our Activity available.
</p>
<h2>Distributing The Activity
</h2>
<p>In this task we'll take our Activity and set it up on <a href="http://activities.sugarlabs.org">http://activities.sugarlabs.org</a>&#160; plus we'll package up the source code so it can be included in Linux distributions.
  <br/></p>
<h2> Add Collaboration
</h2>
<p>Next we'll add code to share e-books with Friends and the Neighborhood.
  <br/></p>
<h2>Add Text To Speech
</h2>
<p>Text to Speech with word highlighting is next.&#160; Our simple project will become a Kindle-killer!
  <br/></p></body></html>