Talk:Sugar Code Snippets: Difference between revisions

From OLPC
Jump to navigation Jump to search
(Added unique ID snippet)
(Moved snippets (contributed by Leejc) from discussion page into article. Meaning of "maintained by OLPC" is unclear.)
Line 1: Line 1:
I'm going to add links/snippets here (mostly from the mailing list); the article has been tagged as "maintained by the OLPC team", so I guess I shouldn't be editing it directly. —[[User:Leejc|Leejc]] 22:43, 28 February 2007 (EST)
I'm going to add links/snippets here (mostly from the mailing list); the article has been tagged as "maintained by the OLPC team", so I guess I shouldn't be editing it directly. —[[User:Leejc|Leejc]] 22:43, 28 February 2007 (EST)
:I've moved the snippets into the article. My understanding is "maintained by the OLPC team" means they keep an eye on it, aiding readers, rather than it being a restriction on contribution. [[User:MitchellNCharity|MitchellNCharity]] 06:52, 10 May 2007 (EDT)

* [http://mailman.laptop.org/pipermail/sugar/2007-February/001528.html Loading an SVG file onto a surface with a transparent background]:

target = ctx.get_target()
buf = target.create_similar(cairo.CONTENT_COLOR_ALPHA, w, h)

* [http://mailman.laptop.org/pipermail/sugar/2007-February/001547.html Measuring an SVG file's original dimensions]

dimensions = handle.get_dimension_data()
width = dimensions[0]
height = dimensions[1]

* [http://mailman.laptop.org/pipermail/sugar/2007-March/002028.html Getting a unique ID for the XO user]:

from sugar import profile
key = profile.get_pubkey()
# If you want a shorter key, you can hash that like:
from sugar import util
key_hash = util._sha_data(key)
hashed_key = util.printable_hash(key_hash)

Revision as of 10:52, 10 May 2007

I'm going to add links/snippets here (mostly from the mailing list); the article has been tagged as "maintained by the OLPC team", so I guess I shouldn't be editing it directly. —Leejc 22:43, 28 February 2007 (EST)

I've moved the snippets into the article. My understanding is "maintained by the OLPC team" means they keep an eye on it, aiding readers, rather than it being a restriction on contribution. MitchellNCharity 06:52, 10 May 2007 (EDT)