[pygtk] Draw text over image

ilius saeed.gnu at gmail.com
Sat Jun 6 06:52:36 WST 2009


I need to draw a text on a pixbuf (and use in tray icon). I found a way that
alraedy WORKS on GNU/Linux (varoius disto's with PyGTK >= 2.10.x) and
windows-xp (with PyGTK 2.12.1). But that was very hard to find this way by
too many searching an too many experimentation. Then I put my code here
maybe help other programmers (that will google on their problem) 
My code looks like this:

pixbuf = gtk.gdk.pixbuf_new_from_file('bx-green.png')
drawable = pixbuf.render_pixmap_and_mask(alpha_threshold=127)[0]
textLay = self.dialog.create_pango_layout(numLocal(ddate[2]))
(w, h) = textLay.get_pixel_size()
drawable.draw_layout(drawable.new_gc(), (22-w)/2.0, 5+(19-h)/2.0, textLay,
None, None)
self.trayPix.get_from_drawable(drawable,
self.dialog.get_screen().get_system_colormap(), 0, 0, 0, 0, -1, -1)
self.statusIcon.set_from_pixbuf(self.trayPix)

-- 
View this message in context: http://www.nabble.com/Draw-text-over-image-tp18391145p23896698.html
Sent from the Gtk+ - Python mailing list archive at Nabble.com.



More information about the pygtk mailing list