Talk:Sugar Code Snippets

From OLPC
Revision as of 22:59, 29 March 2007 by Leejc (talk | contribs) (Added unique ID snippet)
Jump to navigation Jump to search

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)