'Sets a new text in the pane, repr\'ing it if needed.
:param use_repr: Use similar to repr() or not. We don\'t use repr()
because repr() also escapes new lines, and tabs, but
we would like to keep those as they can be represented
properly in a textview.
:param newtext: the new text of the pane.'

def set_text(self, newtext, use_repr=False):

    self.clear()
    iterl = self.buffer.get_end_iter()
    if use_repr:
        newtext = self._repr(newtext)
    else:
        newtext = newtext.replace('\x00', '\\x00')
        try:
            newtext = unicode(newtext)
        except:
            newtext = repr(newtext)[1:(-1)]
    self.buffer.insert(iterl, newtext)
