The workaround is to find the index within GetStrings(), but I'm not
sure about the order.
Finally: is this the corrent behaviour of FindString()? Am I missing
something or may it be a bug?
Thanks
Marco
I don't get wx.NOT_FOUND. I get a -1, which means pretty much the same thing. I think it may be a bug as well, but we'll have to wait for Robin to be sure.
The workaround is to find the index within GetStrings(), but I'm not
sure about the order.
Finally: is this the corrent behaviour of FindString()? Am I missing
something or may it be a bug?
It might be a bug, but if so it is probably Microsoft's. The Windows version of wxListBox::FindString is just a thin wrapper around the ListBox_FindStringExact API. Although MSDN doesn't say anything about that reacting differently to empty strings...
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
points to the null-terminated string to search for.
I surmise that an empty string is NOT null-terminated, but simply isn’t, while the null-termination is a particular value but anyway a value, like zero. If this is correct, we are not coping with a real bug, but in order to find the true result of FindString(“”) a workaround is needed. Something like:
if result == wx.NOT_FOUND:
for i in range(list.Count):
if list.GetString(i) == "": return i
print ‘GetStrings().index(“”):’, list.GetStrings().index(“”) #This is
a workaround
app.MainLoop()
The workaround is to find the index within GetStrings(), but I’m not
sure about the order.
Finally: is this the corrent behaviour of FindString()? Am I missing
something or may it be a bug?
It might be a bug, but if so it is probably Microsoft’s. The Windows version of wxListBox::FindString is just a thin wrapper around the ListBox_FindStringExact API. Although MSDN doesn’t say anything about that reacting differently to empty strings…
points to the null-terminated string to search for.
I surmise that an empty string is NOT null-terminated, but simply isn't, while the null-termination is a particular value but anyway a value, like zero.
A NULL terminated empty string is a well known thing. It's simply a sequence of bytes where the first (and only) item is a zero byte. If wx had problems making one of those then there would be tons of problems all over the place.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!