Search code examples
wxpythonwxtextctrl

Best way to replace an arbitrary row in a multiple line wxTextCtrl


GetLineText is great for getting a particular line, but there is no corresponding SetLineText. If one existed, that's what I'm looking for. Since it doesn't appear to, what's the best way to handle this?

Note: I don't want to replace ALL of the text each time as I'm concerned about performance. My use case has me replacing a line (or range of lines) for every character change in another control. So a solution which has me calling SetValue is not what I'm looking for.


Solution

  • I think what you're looking for is the Replace() method:

    Replace(self, from, to, value)

    http://wxpython.org/docs/api/wx.TextCtrl-class.html