[sugar] pango on xo question
Erik Blankinship
erikb at mediamods.com
Thu Nov 8 18:55:50 EST 2007
Sorry. I've cleaned up the code.
I am wondering why I can't get back a gtk.Image displaying "hi" when
todisk=False on an xo, but can get the "hi" image with todisk=False when in
sugar-jhbuild on fedora. (If todisk=True on either platform, I get back the
intended Image).
Hope that clarifies my confusion some :-)
def createCountdownPng( self ):
> todisk = True
>
> w = 55
> h = w
> if (todisk):
> cimg = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
> ctx = cairo.Context(cimg)
> else:
> pixmap = gtk.gdk.Pixmap(None, w, h, 24)
> ctx = pixmap.cairo_create()
> ctx.rectangle(0, 0, w, h)
> ctx.set_source_rgb(0, 0, 0)
> ctx.fill()
>
> pctx = pangocairo.CairoContext(ctx)
> play = pctx.create_layout()
> font = pango.FontDescription("sans 30")
> play.set_font_description(font)
> play.set_text( "hi" )
> dim = play.get_pixel_extents()
> ctx.translate( -dim[0][0], -dim[0][1] )
> xoff = (w-dim[0][2])/2
> yoff = (h-dim[0][3])/2
> ctx.translate( xoff, yoff )
> pctx.show_layout(play)
>
> img = gtk.Image()
> if (todisk):
> path = os.path.join("tmp", "hi.png")
> cimg.dto_png(path)
> numPixbuf = gtk.gdk.pixbuf_new_from_file(path)
> img.set_from_pixbuf( numPixbuf )
> else:
> img.set_from_pixmap(pixmap, None)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.laptop.org/pipermail/sugar/attachments/20071108/f3c0b6f5/attachment.htm
More information about the Sugar
mailing list