Difference between revisions of "Activity Team/Compatibility Tips"

From Sugar Labs
Jump to navigation Jump to search
m (add category)
Line 34: Line 34:
 
  toolbox = activity.ActivityToolbox(self)
 
  toolbox = activity.ActivityToolbox(self)
 
  toolboxheight = toolbox._activity_toolbar.size_request()[1]
 
  toolboxheight = toolbox._activity_toolbar.size_request()[1]
 +
 +
=== import tarfile ===
 +
At some point, the behavior of the Python tarfile library seems to have changed (I've not yet hunted down the documentation.) In any case, on Build 767, it was generating .tar suffixes and on later builds (newer Python libraries?) it was generating .gtar suffixes. I got burnt by this in Turtle Art so now I check for both.
 +
 +
if file_path[-5:] == ".gtar" or file_path[-4:] == ".tar":
 +
  
 
[[Category:Activity Team]]
 
[[Category:Activity Team]]

Revision as of 12:04, 12 August 2009

Compatibility Tips

SUGAR_BUNDLE_VERSION

Some earlier OLPC builds (e.g., 703) do not have a bundle version environment variable, so you need to catch an exception if you want to access the version.

try:
    version = os.environ['SUGAR_BUNDLE_VERSION']
except:
    version = "unknown"

get_activity_root()

Some earlier OLPC builds (e.g., 656) do not have activity.get_activity_root(), so you need to catch an exception if you want to access the version.

try:
    path = activity.get_activity_root()
except:
    # early versions of Sugar (656) didn't support get_activity_root()
    path = "/home/olpc/.sugar/default/org.sugarlabs.[your activity name]"

svg:

Some earlier OLPC builds (e.g., 656) use an older version of the gtk svg libraries that don't process svg files that use the <svg:tag> syntax. It seems that removing svg: resolves the rendering problem.

<svg:path> won't work
<path> will work

Screen size

The screen size varies on different hardware platforms. If you develop in an emulator, it is worthwhile trying different sizes to make sure your activity scales properly.

Some useful utilities:

width = gtk.gdk.screen_width()
height = gtk.gdk.screen_height()
toolbox = activity.ActivityToolbox(self)
toolboxheight = toolbox._activity_toolbar.size_request()[1]

import tarfile

At some point, the behavior of the Python tarfile library seems to have changed (I've not yet hunted down the documentation.) In any case, on Build 767, it was generating .tar suffixes and on later builds (newer Python libraries?) it was generating .gtar suffixes. I got burnt by this in Turtle Art so now I check for both.

if file_path[-5:] == ".gtar" or file_path[-4:] == ".tar":