import gtk
from gtk import gdk
traySize = 24
statusIcon = gtk.StatusIcon()
trayPixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, True, 8, traySize, traySize)
## Every time you want to change the image/text of status icon:
pixbuf = gtk.image_new_from_stock(gtk.STOCK_EDIT, traySize).get_pixbuf()
pixmap = pixbuf.render_pixmap_and_mask(alpha_threshold=127)[0] ## pixmap is also a drawable
textLay = statusIcon.create_pango_layout('Hi')
## Calculate text position (or set it manually)
(text_w, text_h) = textLay.get_pixel_size()
x = (traySize-text_w) / 2
y = traySize/4 + int((0.9*traySize - text_h)/2)
## Finally draw the text and apply in status icon
pixmap.draw_layout(pixmap.new_gc(), x, y, textLay, gdk.Color(255, 0, 0))## , foreground, background)
trayPixbuf.get_from_drawable(pixmap, self.get_screen().get_system_colormap(), 0, 0, 0, 0, traySize, traySize)
statusIcon.set_from_pixbuf(trayPixbuf)