You are right; I should have realized it. In fact, I should have realized what the problem was when I saw the ordered dictionary dependency in the PYLbc documentation (it is developed on python2.5). I never thought of a dict as not caring about order like a list does, but your explanation of it being simply a hash table makes sense (I realize it is not intended as a full explanation and that there is much reading to be found, but I do know what a hash table/associative array is and its basic mechanism). My first question stands, though, regarding a ListBox item's "ClientData" value (and I have tried to find an answer to this one and can only find a reference to sorting items, which is only possible within the control... nothing detailed.) Looking at the AddListbox I see that the ClientData is set to an integer i, where i goes from 0 to the number of list items minus 1. Oddly, the "values" parameter of the method is never used in the method itself, so I am unclear as to just why it exists at all in the method. On 6/18/11, Q <q@xxxxxxxxxxxxxxxxxx> wrote: > Alex, > May I recommend actually reading about the basic Python data types > before attempting to create even simple applications? > In particular, you should be aware that a dictionary is an inherently > unordered type, as the underlying datastructure, namely a hash table, is > unordered. > The point of such a structure is for associating a key with a value. If > you need to preserve ordering, either use an ordered dict (a Python 2.7+ > feature), or perhaps an alist-like sequence of tuples. > You can also pull the keys out of a dictionary and sort them for use in > a list box, something akin to > lb = wx.ListBox(parent=self, value=sorted(some_dict)) #Note that this is > taking advantage of the fact that iterating dicts gives their keys. > But in all seriousness, please do go study the basics before hitting the > list with a question like this. > Q > > > > > On 6/18/2011 9:17 PM, Alex Hall wrote: >> Hi all, >> When I use a ListBox, I see that I can give it a names list and a >> values list. I understand that names are what is shown to the user, >> but what do values do? They do not seem to be used in the AddListBox >> method at all. >> >> A second question goes along with this: when I pass a list to be the >> names list in a ListBox, all is well. When I pass a dictionary, >> though, all my items suddenly get out of order. For example, if I pass >> ["apple", "banana", "orange"] as the names list in the AddListBox >> method, the items appear in that order. When I instead do this: >> items={ >> "apples":"red", >> "bananas":"yellow", >> "oranges":"orange" >> } >> and then add to my dialog: >> dlg.AddListBox(label="fruit", names=items.keys()) >> I get a list with the three fruits out of order, appearing as "apples, >> oranges, bananas" in the list instead. I imagine this is a python >> problem in the keys() method of the dictionary, but I cannot imagine >> why it would do it at all. How do I get around it so that items appear >> in the same order as they do in my dictionary? Thanks! >> >> > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > > -- Have a great day, Alex (msg sent from GMail website) mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind