Talk:Activity tutorial: Difference between revisions

From OLPC
Jump to navigation Jump to search
(Some Experiences)
m (Reverted edits by 87.253.3.111 (Talk) to last revision by Quozl)
 
(19 intermediate revisions by 7 users not shown)
Line 49: Line 49:


2. No icon
2. No icon

Answer: Using '<iconfilename>' instede of '<iconfilename>.svg' In the info file.
Answer: Using '<iconfilename>' instead of '<iconfilename>.svg' in the info file.


3. Activity cannot start
3. Activity cannot start

Answer: Change the file permission by 'chmod' and 'chown' command
Answer: Change the file permission by 'chmod' and 'chown' command ----[[User:bolu|Yibo Lin]] 16:10, 09 January 2008 (EDT)

== More experiences... ==

You mileage may vary:

1. If the icon file file does not exist, then a blank icon will be silently substituted. That is, the empty black space in your bar launches the icon.
2. The various files could use a lot more documentation.
3. There is no hint here as to how to uninstall the application from Sugar in order to make changes.
4. The instructions are for development on an image, but straight on the XO works as well.


== Getting the Example to Run ==

I did finally get the sample code as cut/pasted from the tutorial to run on my olpc hardware. Some observations:


* Typos et al can be treacherous. Sugar's only error behavior is to sit indefinitely in the "Starting" state when you click on the icon. It'd sure be nice to know where logging takes place.
* A useful debugging trick is to fire up the python interpreter at the command line and try to import your main class ("HelloWorldActivity/HelloWorldActivity.py" in the example). After you type in:
python
from HelloWorldActivity import HelloWorldActivity
you should return to a python prompt with no errors. If you have Troubles it is probably wise to fix them.
* You can find log files in /home/olpc/.sugar/default/logs. If you have a python error, you will find a log named for the "service_name" in the activity.info file.
* When I used the "python setup.py dev" command it created a link in ${HOME}/Activities called "HelloWorldActivity.activity.activity". While thrashing around trying to Make Stuff Work I changed the TLD name to "HelloWorldActivity" in order to get a link called "HelloWorldActivity.activity" there. The "cmd_dev" routine did create a ${HOME}/Activities directory for me the first time I ran it.
* Clicking the "Remove" link on the icon apparently only removes it from the UI; the way to remove it so that you can re-add it with the setup.py script is to manually remove the softlink from ${HOME}/Activities.
* In the tutorial, the "class =" line of the activity.info file is commented out. I can run HelloWorldActivity only if that line is active (e.g. the "#" in front of it is removed).
* The "exec =" line of the activity.info file appears to be irrelevant. I can run the HelloWorld activity just fine with it commented out, and when I try to run "sugar-activity HelloWorld.HelloWorld" from the command line I get an exception which I think means class not found. The last line is
&lt;type 'exceptions.ImportError'&gt;: No module named HelloWorldActivity
This appears whether or not I am in the same directory with "HelloWorldActivity.py".
* Of course I touched the "HelloWorldActivity/NEWS" file and removed the ".svg" from the icon name in the activity.info file as detailed above. And I double-checked that the two python scripts were executable and owned by user "olpc", group "olpc". I also made sure to keep the manifest file up to date with these changes, although I suspect it's only used when I bundle this little gem into a ".xo" file.
[[User:Cshapiro|Cshapiro]] 11:05, 22 January 2008 (EST)

Using the icon text as is did not work for me -- no icon would show so no way to start the app (as noted above, running via sugar-activity generated the "no module error". Copying another .svg file on the XO to the activity folder, and making the necessary icon filename change in the activity.info file did the trick. Also creating a new icon via Inkspace worked. [[User:jd555|jd555]] 15:26, 27 December 2008 [CST]

== Speaking of typos ==
Why is that comment in front of the class in activity.info? It seems to cause a lot of confusion.

== Ignore lbgnomevfs warnings... ==

You might notice in the logs a warning like:

libgnomvfs-WARNING **: unable to create ~/.gnome2 directory ...

You can safely ignore it, per Marco Gitti on the dev mailing list.

== English lost in translation ==

Could we get the English version of this back and preserve the new translation in a page specific to the language?

Latest revision as of 17:12, 12 October 2012

sugar-install-bundle

This script does not exist. Install instructions should exist for:

  • easy command-line install
  • file-by-file instructions from a root shell
  • install via the web browser

GTK and SDL

Not every app performs tolerably OK in Python. Some of us use C with GTK. Some of us use C with SDL. There should be "hello world" examples for these as well.

Critique

  • The word activity seems highly overloaded/overused; e.g. three different uses in "hello.activity/activity/activity.info". Is it too late to shorten this? Do we really need this much structure and repetition? Similar for the sugar package structure; there's a toplevel package sugar with a subpackage named activity which itself contains a module named activity (and I think that defines a class Activity :-). I'm worried that this is going to cause confusion and hard-to-debug bugs where in a particular context it's hard to guess what the name 'activity' refers to. --Guido van Rossum
  • As this page is under the "Getting Started" heading, perhaps somewhere....

1) ...it could address the questions of "What language are activities written in?" (or make it more clear that all activities are run by an interpreter built into Sugar?)

2) ...and either explicitly say "There is no compiling of source code to do, the equivalent is part of the "bundling" process", or tell the reader more about the compiling.

The "source code" "heart" of the HelloWorld example is easy enough to find in what already exists.

Image for Emulation Environment

  • Which image should we be using to performance the helloworld exercise. I tried the livecd_sdk image with vmware and it didn't work.

duplicate use of HelloWorldActivity

I speculate that HelloWorldActivity used twice, as both the name of the module and the name of the class within the module, confuses people. It confuses me, anyway. I'd like to change module name to 'main'. Any reasonable name, other than HelloWorldActivity, will work, because the file resides underneath the HelloWorld.activity subdirectory. Anybody object to this? RussNelson 18:08, 16 July 2007 (EDT)

Better yet, to make things really clear: thing1, thing2, thing3, etc. AlbertCahalan 20:46, 15 September 2007 (EDT)

updates as of build 538

Tim.millerdyck 19:31, 29 July 2007 (EDT)

Here are some changes I needed to make to get the example working with Build 538.

  • The setup.py code should have "MyActivityName" changed to "HelloWorldActivity" to work with the example activity
  • The provided HelloWorld-1.xo archive has an out-of-date setup.py file that does not have required bundlebuilder parameters. The file should be edited to reflect what is on the Wiki page with the above change.
  • bundlebuilder complains if a NEWS file is not present. "touch NEWS" in the top-level activity directory to avoid this

Can't get this to work

Hi. I followed the instructions, but when I click on the HelloWorld actibity in the dock, the icon is blank, and the donut just goes grey in one section, never finishes loading. I included the "touch NEWS" command as mentioned above. I'm on build 650. Thanks, --Tomhannen 18:27, 27 December 2007 (EST)

Some Experiences

1. I already have the sugar-jhbuild built successfully however, when I followed this tutorial to do the activity setup by: 'python setup.py dev', I get an error "ImportError: No module named sugar.activity". Any suggestions? Thanks!

Answer: Get it done by running this under the sugar shell by using './sugar-jhbuild shell'

2. No icon

Answer: Using '<iconfilename>' instead of '<iconfilename>.svg' in the info file.

3. Activity cannot start

Answer: Change the file permission by 'chmod' and 'chown' command ----Yibo Lin 16:10, 09 January 2008 (EDT)

More experiences...

You mileage may vary:

1. If the icon file file does not exist, then a blank icon will be silently substituted. That is, the empty black space in your bar launches the icon. 2. The various files could use a lot more documentation. 3. There is no hint here as to how to uninstall the application from Sugar in order to make changes. 4. The instructions are for development on an image, but straight on the XO works as well.


Getting the Example to Run

I did finally get the sample code as cut/pasted from the tutorial to run on my olpc hardware. Some observations:


  • Typos et al can be treacherous. Sugar's only error behavior is to sit indefinitely in the "Starting" state when you click on the icon. It'd sure be nice to know where logging takes place.
  • A useful debugging trick is to fire up the python interpreter at the command line and try to import your main class ("HelloWorldActivity/HelloWorldActivity.py" in the example). After you type in:
python
from HelloWorldActivity import HelloWorldActivity

you should return to a python prompt with no errors. If you have Troubles it is probably wise to fix them.

  • You can find log files in /home/olpc/.sugar/default/logs. If you have a python error, you will find a log named for the "service_name" in the activity.info file.
  • When I used the "python setup.py dev" command it created a link in ${HOME}/Activities called "HelloWorldActivity.activity.activity". While thrashing around trying to Make Stuff Work I changed the TLD name to "HelloWorldActivity" in order to get a link called "HelloWorldActivity.activity" there. The "cmd_dev" routine did create a ${HOME}/Activities directory for me the first time I ran it.
  • Clicking the "Remove" link on the icon apparently only removes it from the UI; the way to remove it so that you can re-add it with the setup.py script is to manually remove the softlink from ${HOME}/Activities.
  • In the tutorial, the "class =" line of the activity.info file is commented out. I can run HelloWorldActivity only if that line is active (e.g. the "#" in front of it is removed).
  • The "exec =" line of the activity.info file appears to be irrelevant. I can run the HelloWorld activity just fine with it commented out, and when I try to run "sugar-activity HelloWorld.HelloWorld" from the command line I get an exception which I think means class not found. The last line is
<type 'exceptions.ImportError'>: No module named HelloWorldActivity

This appears whether or not I am in the same directory with "HelloWorldActivity.py".

  • Of course I touched the "HelloWorldActivity/NEWS" file and removed the ".svg" from the icon name in the activity.info file as detailed above. And I double-checked that the two python scripts were executable and owned by user "olpc", group "olpc". I also made sure to keep the manifest file up to date with these changes, although I suspect it's only used when I bundle this little gem into a ".xo" file.

Cshapiro 11:05, 22 January 2008 (EST)

Using the icon text as is did not work for me -- no icon would show so no way to start the app (as noted above, running via sugar-activity generated the "no module error". Copying another .svg file on the XO to the activity folder, and making the necessary icon filename change in the activity.info file did the trick. Also creating a new icon via Inkspace worked. jd555 15:26, 27 December 2008 [CST]

Speaking of typos

Why is that comment in front of the class in activity.info? It seems to cause a lot of confusion.

Ignore lbgnomevfs warnings...

You might notice in the logs a warning like:

libgnomvfs-WARNING **: unable to create ~/.gnome2 directory ...

You can safely ignore it, per Marco Gitti on the dev mailing list.

English lost in translation

Could we get the English version of this back and preserve the new translation in a page specific to the language?