def _set_background(self, value, attrlist): if value not in COLOR_RGB: logger.info('This color is not supported => %s', value) color = COLOR_RGB.get(value, COLOR_RGB['black']) if hasattr(Pango, 'AttrBackground'): attrlist.change(Pango.AttrBackground( color[0], color[1], color[2], 0, -1))
def recalc_edges(self): if not hasattr(self, 'layout'): return del self.layout show_text = self.attrs_changed() r, g, b = utils.selected_colors["fill"] r *= 65536 g *= 65536 b *= 65536 if self.index > self.end_index: bgsel = Pango.AttrBackground(int(r), int(g), int(b), self.end_index, self.index) else: bgsel = Pango.AttrBackground(int(r), int(g), int(b), self.index, self.end_index) self.attrlist.insert(bgsel) self.layout = Pango.Layout(self.Pango_context) self.layout.set_text(show_text) self.layout.set_attributes(self.attrlist) self.recalc_position()