From: Sean K. F. <skf...@gm...> - 2007-11-15 22:13:33
|
I can't help but wonder... If you are indeed populating the text control with a list of filenames yourself, why not increment a counter while you build this list and cache that number off for later reference? Better yet, why not populate a list (list object, not list control) and use that for the basis of the content within text control? You can then leverage the full capabilities of the list object and every time it is updated, simply reference some "redraw" routine to populate the text control with the current contents of the list? Personally, I do not recommend relying on the control to return what's in it, or how many of something it contains, you should begin thinking about how you can abstract that data out to your code and manage it at the application level, rather than the view/UI level, and only use the UI to display the underlying application data... If that makes any sense... - Sean On Nov 15, 2007 4:40 PM, Kevin Altis <al...@se...> wrote: > > 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 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- Thanks! Sean Sean K. Friese skf...@gm... This email message, including any attachment(s) hereto, is intended only for the addressee and may contain information that is legally privileged, confidential and/or exempt from disclosure under applicable law. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you have received this communication in error, or are not the named recipient(s), please immediately notify the sender and delete this e-mail message. |