Frage

I need to delete X lines from the middle of a textctrl starting from line number Y

Is there any easy way to do this? I can't see one: it seems like I have to somehow search through the contents of the TextCtrl counting newlines to find the position of Y...

War es hilfreich?

Lösung

    if self._log.GetNumberOfLines() > MAX_LINES:
        if self._log.GetLineText(DELETION_POINT) != DELETION_LINE:
            start = self._log.XYToPosition(0, DELETION_POINT)
            self._log.SetInsertionPoint(start)
            self._log.WriteText(DELETION_LINE)
        while (self._log.GetNumberOfLines() > MAX_LINES):
            start = self._log.XYToPosition(0, DELETION_POINT+1)
            len = self._log.GetLineLength(DELETION_POINT+1)
            self._log.Remove(start, start+len+1)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top