From: Kevin A. <al...@se...> - 2007-11-15 21:40:39
|
On Nov 15, 2007, at 1:05 PM, Tony Cappellini wrote: >> self.components.yourComponentNameHere.getNumberOfLines() should work. > >> If it doesn't, then I would like to know what the line endings are as >> well as which platform and versions of wxPython and PythonCard you're >> using. > > The platform is Windows > The line endings are "\n" > > Wx version 2.8.4.2 > Pythoncard version is the latest 0.8.2 > > > I've just tried this again today- while verifying the line endings, > and getNumberOfLines() is returning a valid number instead of 1 > > I'll keep watching this to see if it changes After looking at the documentation again for the wx.TextCtrl (TextArea is based on that widget) method GetNumberOfLines, I would avoid using it to count lines if you want to be consistent in your results across platforms. Here's the excerpt from the docs... """ wxTextCtrl::GetNumberOfLines int GetNumberOfLines() const Returns the number of lines in the text control buffer. Remarks Note that even empty text controls have one line (where the insertion point is), so GetNumberOfLines() never returns 0. For gtk_text (multi-line) controls, the number of lines is calculated by actually counting newline characters in the buffer. You may wish to avoid using functions that work with line numbers if you are working with controls that contain large amounts of text. """ In addition I noticed that the result returned on Windows was actually the wrapped line count, not the number of newlines. So a safer, more consistent result would be to get a count with something like... len(self.components.myTextArea.text.split('\n')) ka |