pythonpython-3.xwxtextctrlwxpython

Set InsertionPoint to end of current line in wxPython wx.TextCtrl


Ok, so I know I can do:

curPos = self.LogWindow.GetInsertionPoint
lineNum = self.LogWindow.GetRange( 0, self.LogWindow.GetInsertionPoint() ).split("\n")
lineText = self.LogWindow.GetLineText(lineNum)

But how can I set the InsertionPoint to the end of the current lint?

Current line of course meaning: the line where the InserionPoint is currently located.

Any help appreciated :).


Solution

  • Try:

        curPos = self.log.GetInsertionPoint()
        curCol,curRow = self.log.PositionToXY(curPos)
        lineNum = curRow
        lineText = self.log.GetLineText(lineNum)
        newPos=self.log.XYToPosition(len(lineText), curRow)
        self.log.SetInsertionPoint(newPos)