wxListCtrl and GetItemText on Windows limits string length to 511

116 views
Skip to first unread message

franz steinhaeusler

unread,
Apr 15, 2017, 12:20:15 PM4/15/17
to wxPython-users
Hello, after a longer research, I found the problem in my application:
On gtk, everything is fine (no string length limit)

But on Windows, if I set a string of length > 511, the string in GetItemText is truncated to 511 characters (or 512 characters, with 0 Byte on the end?)

small example in pycrust Windows:
>>> l=wx.ListCtrl(c)
>>> l.InsertStringItem(0, "h"*700)
0
>>> r = l.GetItemText(0)
>>> print r, len(r)
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh 511
>>>

in Gtk;
>>> l=wx.ListCtrl(c)
>>> l.InsertStringItem(0, "h"*700)
0
>>> r = l.GetItemText(0)
>>> print r, len(r)
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh 700
>>>


If I can solve that problem (I use the EditableListBox), I cannot really use my app on windows (without any serious change).
How can I get windows to deliver *ALL* Characters in the Listbox? Is there any style for that? I there any workaround?

Many thanks in advance!

franz steinhaeusler

unread,
Apr 15, 2017, 12:23:58 PM4/15/17
to wxPython-users
Forgot to mention: Python 2.7, wxPython 2.8.12.1 (same on windows and on ubuntu)

Andrea Gavana

unread,
Apr 15, 2017, 1:16:03 PM4/15/17
to wxpytho...@googlegroups.com
Hi,

It appears it cannot be done:


Although I'm no super expert and I may have missed some info. If it can't be done, then you might want to give UltimateListCtrl a try, I am sure there is no such limitation in there...

By the way, why would you need to display 700 characters in a listctrl item? Even if you do, the column width must be something like 2,000 pixels...

Andrea.




--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

franz steinhaeusler

unread,
Apr 16, 2017, 10:35:06 AM4/16/17
to wxPython-users
Hello Andrea,

first I was away some years from wxPython, I need to come into it again.

My app is a clipboard manager like clipx on windows or parcellite on ubuntu, which I want to have crossplatorm.

I have ported the EditableListbox from wxWidgets Source to python and here I have my problems with the listctrl.
With the editableListbox, I want to view/edit clipboard (and also "snippets" entries. And some clipboard data entries are quiet long.
I want to have Tooltips in Listctrl to view the content and I have an edit button (which calls a dialog with stc Editor) to comfortable edit the entry.


I have already tried your UltimateListCtrl and SuperTooltip (which is a fantastic work from you), but I had some problems/inconsistencies. Maybe I try again, but I think I would have to patch some of your Sources.

franz steinhaeusler

unread,
Apr 16, 2017, 1:34:23 PM4/16/17
to wxPython-users
I thought, I send the testexample. It should demonstrate it best. The annoying thing (so often) ist, that gtk and ms windows behave more different (in wxWidgets/wxPython) than you want to expect.

Just run wxEditableListBox.py. I hope, will be all complete to run and show the problems. Also the button down and up  (I exended original EditableListBox from demo a little bit - for example call external edit window (stc Control) to more comfortable editing.
wxEditableListBox.py
wxStcEditText.py

James Scholes

unread,
Apr 17, 2017, 5:51:55 AM4/17/17
to wxpytho...@googlegroups.com
franz steinhaeusler wrote:
> here I have my problems with the listctrl.
> With the editableListbox, I want to view/edit clipboard (and also
> "snippets" entries. And some clipboard data entries are quiet long.
> I want to have Tooltips in Listctrl to view the content and I have an
> edit button (which calls a dialog with stc Editor) to comfortable edit
> the entry.

If the underlying GUI control doesn't support what you're trying to do,
don't rely on it. Store the clipboard entries separately in some other
structure like a list of strings, rather than having wx do the work for
you. When you show the edit dialog, retrieve the full text of the entry
from your list instead of using ListCtrl.GetItemText.

This is pretty common in GUI apps - the list of clipboard entries is
your data model, the list is your view. Don't confuse the two and the
limitations of the GUI won't matter.
--
James Scholes
http://twitter.com/JamesScholes

franz steinhaeusler

unread,
Apr 17, 2017, 1:48:06 PM4/17/17
to wxPython-users, ja...@jls-radio.com
Hello James,

I thought over the whole thing and decided to solve that the way you mention it.
I chose an extra list of strings, which I update accordingly.

thanks again
Reply all
Reply to author
Forward
0 new messages