From: Tony C. <cap...@gm...> - 2007-11-15 07:20:26
|
I've printed a list of filenames in a textarea widget. I want to see how many filenames are in the widget. When I call GetNumberOfLines() or getNumberOfLines(), they both return 1. Is there a way to query the widget to actually get the number of items printed ? thanks |
From: Phil E. <ph...@li...> - 2007-11-15 09:26:13
|
Tony Cappellini wrote: > I've printed a list of filenames in a textarea widget. > > I want to see how many filenames are in the widget. > > When I call GetNumberOfLines() or getNumberOfLines(), they both return 1. > > Is there a way to query the widget to actually get the number of items printed ? > If you're using a textarea to store a list, wouldn't it be simpler to just use a list widget instead? Then just make a call to len(self.components.listName.items) to find out how many are in there. -- Regards Phil Edwards Brighton, UK |
From: Kevin A. <al...@se...> - 2007-11-15 15:17:56
|
On Nov 14, 2007, at 11:20 PM, Tony Cappellini wrote: > I've printed a list of filenames in a textarea widget. > > I want to see how many filenames are in the widget. > > When I call GetNumberOfLines() or getNumberOfLines(), they both > return 1. > > Is there a way to query the widget to actually get the number of > items printed ? > > > thanks 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. If you end up using a List component instead then getCount() is the method you want. ka |
From: Tony C. <cap...@gm...> - 2007-11-15 17:52:00
|
I had posted a question a few days ago- regarding Which Text widget to use. I need a widget with a scroll bar because the list is likely to be larger that the space for the widget. I believe the list widget doesn't have a scroll bar, that's why I'm using the TexArea widget On Nov 15, 2007 1:25 AM, Phil Edwards <ph...@li...> wrote: > > Tony Cappellini wrote: > > I've printed a list of filenames in a textarea widget. > > > > I want to see how many filenames are in the widget. > > > > When I call GetNumberOfLines() or getNumberOfLines(), they both return 1. > > > > Is there a way to query the widget to actually get the number of items printed ? > > > > If you're using a textarea to store a list, wouldn't it be simpler to > just use a list widget instead? Then just make a call to > len(self.components.listName.items) to find out how many are in there. > > -- > > Regards > > Phil Edwards > Brighton, UK > |
From: Kevin A. <al...@se...> - 2007-11-15 19:44:34
|
On Nov 15, 2007, at 9:51 AM, Tony Cappellini wrote: > I had posted a question a few days ago- regarding Which Text widget > to use. > I need a widget with a scroll bar because the list is likely to be > larger that the space for the widget. > I believe the list widget doesn't have a scroll bar, that's why I'm > using the TexArea widget The scrollbar appears once you have more items in the list than can be displayed at one time. That is pretty standard for a list widget. ka |
From: Tony C. <cap...@gm...> - 2007-11-15 19:45:42
|
Ok- thanks I'll reply to your questions- shortly- when I"m in front of the machine where I found the problem with GetNumberOfLines() On Nov 15, 2007 11:44 AM, Kevin Altis <al...@se...> wrote: > > On Nov 15, 2007, at 9:51 AM, Tony Cappellini wrote: > > > I had posted a question a few days ago- regarding Which Text widget > > to use. > > I need a widget with a scroll bar because the list is likely to be > > larger that the space for the widget. > > I believe the list widget doesn't have a scroll bar, that's why I'm > > using the TexArea widget > > The scrollbar appears once you have more items in the list than can > be displayed at one time. That is pretty standard for a list widget. > > ka > > |
From: Tony C. <cap...@gm...> - 2007-11-15 21:05:04
|
> 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 |
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 |
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. |