Talk:Sugar Code Snippets: Difference between revisions

From OLPC
Jump to navigation Jump to search
mNo edit summary
(Added unique ID snippet)
Line 11: Line 11:
width = dimensions[0]
width = dimensions[0]
height = dimensions[1]
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 22:59, 29 March 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)

target = ctx.get_target()
buf = target.create_similar(cairo.CONTENT_COLOR_ALPHA, w, h)
dimensions = handle.get_dimension_data()
width = dimensions[0]
height = dimensions[1]
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)