Feed wxComboBox with dictionary/hash
rogue_pedro at yahoo.com
Thu Jun 22 18:23:22 CEST 2006
Roland Rickborn wrote:
> Hi folks,
> As the subject says, I'd like to feed a wx.ComboBox with a
> dictionary/hash. According to the posting of Stano Paska ("wxComboBox
> <> combobox", 20 Jul. 2004), there seems to be a way to do this:
> > You must use something like
> > combo.Append('aaa', 'a')
> > combo.Append('bbb', 'b')
> > ...
> My problem is:
> my data has thousands of entries. Therefore, I'd like to feed the
> combobox with a dictionary (which itself is fed by a database query).
> My first question:
> how can a wx.ComboBox be fed by a dictionary?
> Roland R.
I don't know if this is the best way to do this, but you could just
feed the wx.ComboBox from the dict in a loop like this:
for k, v in data_dict.iteritems(): combo.Append(k, v)
>From the manual link that Iain King posted
it appears that you might be able to pass a list of strings to the
Append() method. However, it also appears that you wouldn't be able to
associate any "clientData" with the strings.
More information about the Python-list