4 def text_box_centered(ctx, widget, w_width, w_height, text, font_desc=None):
5 style = widget.rc_get_style()
6 text_color = style.text[gtk.STATE_PRELIGHT]
7 red, green, blue = text_color.red, text_color.green, text_color.blue
8 text_color = [float(x)/65535. for x in (red, green, blue)]
12 font_desc = style.font_desc
13 font_desc.set_size(14*pango.SCALE)
15 pango_context = widget.create_pango_context()
16 layout = pango.Layout(pango_context)
17 layout.set_font_description(font_desc)
19 width, height = layout.get_pixel_size()
21 ctx.move_to(w_width/2-width/2, w_height/2-height/2)
22 ctx.set_source_rgba(*text_color)
23 ctx.show_layout(layout)