Loading wx.Choice and wx.ListBox

For these two very similar controls, is there any sort of method that allows them to be loaded like such:

   strings = ['Str1', 'Str2']
   data = [data1, data2]
   choice.LoadEm(strings, data)

-or-

   stuff = [
     ['Str1', data1],
     ['Str2', data2],
   ]
   choice.LoadEm(stuff)

-or maybe-

   stuff = {
     data1: 'Str1',
     data2: 'Str2',
   }
   choice.LoadEm(stuff)

Thanks,
Michael

I assume "dataN" is what you like in choice "ClientData", I don't think that there is a method out of the box as "choice.AppendItems" doesn't allow to set the client data.

You could have a derived class from choice and have a method something along these line:

   stuff = [
     ['Str1', data1],
     ['Str2', data2],
   ]
   mychoice.LoadEm(stuff)

def LoadEm(self, items):
    for item in items:
       self.Append(item[0], item[1]

Werner

···

On 10/31/2011 04:47 PM, Michael Hipp wrote:

For these two very similar controls, is there any sort of method that allows them to be loaded like such:

  strings = ['Str1', 'Str2']
  data = [data1, data2]
  choice.LoadEm(strings, data)

-or-

  stuff = [
    ['Str1', data1],
    ['Str2', data2],
  ]
  choice.LoadEm(stuff)

-or maybe-

  stuff = {
    data1: 'Str1',
    data2: 'Str2',
  }
  choice.LoadEm(stuff)

Thanks,
Michael

Thanks.

How does the overloaded Set() method work in Python? On the surface it looks like it might do this:

void Set (const wxArrayString &choices, void *clientData)
   Clears the list box and adds the given strings to it.

But I'm unsure what *clientData might be in Python (a list of client data?) the docs seem to suggest it might be a C++ array (of what?).

Thanks,
Michael

···

On 10/31/2011 11:03 AM, werner wrote:

I assume "dataN" is what you like in choice "ClientData", I don't think
that there is a method out of the box as "choice.AppendItems" doesn't
allow to set the client data.

You could have a derived class from choice and have a method something
along these line:

stuff = [
['Str1', data1],
['Str2', data2],
]
mychoice.LoadEm(stuff)

def LoadEm(self, items):
for item in items:
self.Append(item[0], item[1]

Because of these issues the Set wrapper simply ignores the clientData parameter.

···

On 10/31/11 9:51 AM, Michael Hipp wrote:

How does the overloaded Set() method work in Python? On the surface it
looks like it might do this:

void Set (const wxArrayString &choices, void *clientData)
Clears the list box and adds the given strings to it.

But I'm unsure what *clientData might be in Python (a list of client
data?) the docs seem to suggest it might be a C++ array (of what?).

--
Robin Dunn
Software Craftsman