ListBox: Append vs Insert

45 views
Skip to first unread message

cappy2112

unread,
Dec 17, 2009, 3:27:12 PM12/17/09
to wxPython-users

Is it normal for the behavior of ListBox.Append() to add an item to
the beginning of the list instead of the end?
Is this not more of a prepend operation?

I've replaced calls to Append() with Insert(textItem, Listbox.Count)-
which gives me the behavior I expected with Append.

Cody Precord

unread,
Dec 17, 2009, 3:34:03 PM12/17/09
to wxpytho...@googlegroups.com
Hi,

On Thu, Dec 17, 2009 at 2:27 PM, cappy2112 <capp...@gmail.com> wrote:
>
> Is it normal for the behavior of ListBox.Append() to add an item to
> the beginning of the list instead of the end?

No, not unless the listbox is empty then the end is also the beginning

> Is this not more of a prepend operation?
>
> I've replaced calls to Append() with Insert(textItem, Listbox.Count)-
> which gives me the behavior I expected with Append.

Append should add it to the end and it does on my machine.

What OS, version of wxPython, and architecture (32/64 bit) are you using?


Cody

cappy2112

unread,
Dec 17, 2009, 3:41:15 PM12/17/09
to wxPython-users

>>No, not unless the listbox is empty then the end is also the beginning
I don't think one can see where an item is inserted in this case,
since it is the only one.
When adding subsequent items, I can easily see them being added to the
beginning.


> What OS, version of wxPython, and architecture (32/64 bit) are you using?

XP, SP2. '2.8.9.1 (msw-ansi)', 32-bit. We use Python 2.3- so I can't
go to any newer versions of wx because there are no binaries for 2.3
after this version of wx.

I also see this behavior on my laptop, which is running Windows 7, 32-
bit, probably a lot more recent version of wxPython, because I am
using Python 2.5 on the laptop.

Cody Precord

unread,
Dec 17, 2009, 4:08:34 PM12/17/09
to wxpytho...@googlegroups.com
Hi,

On Thu, Dec 17, 2009 at 2:41 PM, cappy2112 <capp...@gmail.com> wrote:
> XP, SP2. '2.8.9.1 (msw-ansi)', 32-bit. We use Python 2.3- so I can't
> go to any newer versions of wx because there are no binaries for 2.3
> after this version of wx.
>
> I also see this behavior on my laptop, which is running Windows 7, 32-
> bit, probably a lot more recent version of wxPython, because I am
> using Python 2.5 on the laptop.

On my windows xp box py2.5.4 wx2.10.1 this behavior is not
reproducible, so not sure what else I can tell you.

See attached test app.


Cody

test.py

Cody Precord

unread,
Dec 17, 2009, 4:52:17 PM12/17/09
to wxpytho...@googlegroups.com
Hi,

Actually one thing did come to mind, are you using any style flags on
your listbox?

Using LB_SORT would modify the behavior of how things are added to the
list by Append and could explain what your seeing


Cody

cappy2112

unread,
Dec 18, 2009, 4:10:28 PM12/18/09
to wxPython-users

> Actually one thing did come to mind, are you using any style flags on
> your listbox?

Yes, but not the sort style.

I am using these
wx.TE_READONLY|wx.LB_HSCROLL|wx.LB_MULTIPLE


Cody Precord

unread,
Dec 18, 2009, 4:16:31 PM12/18/09
to wxpytho...@googlegroups.com
Hi,

TE_READONLY is a TextCtrl style flag so you shouldnt use it with a list box
and by coincidence look at this

>>>import wx
>>>wx.TE_READONLY
16
>>>wx.LB_SORT
16


Cody

cappy2112

unread,
Dec 22, 2009, 1:45:18 AM12/22/09
to wxPython-users

> TE_READONLY is a TextCtrl style flag so you shouldnt use it with a list box
> and by coincidence look at this

That explains it all. I had originally used a TextCtrl then switched
to a ListBox without changing all of the style options.

Thanks

Reply all
Reply to author
Forward
0 new messages