def _ensureColor(self, pref): """ Ensures that the tags for pref_normal and pref_bold are set in the text buffer """ tb = self.readView.get_buffer() if not pref in self.colors: color = uistuff.genColor(len(self.colors) + 1, self.startpoint) self.colors[pref] = color color = [int(c * 255) for c in color] color = "#" + "".join([hex(v)[2:].zfill(2) for v in color]) tb.create_tag(pref + "_normal", foreground=color) tb.create_tag(pref + "_bold", foreground=color, weight=Pango.Weight.BOLD)