On Mon, 2004-11-01 at 13:48 +0800, Austin wrote:
............... ..
self.diskList = ['3','4','5']
self.cB = wxComboBox(self ,-1,wxDefaultPosi tion,wxDefaultS ize,self.diskLi st)
............... ..
The code is executed initially.
If i want to update only the diskList, what could i do?
I take it you want the list and the wxComboBox tied together so that
updating the python list automatically updates the wxComboBox. There is
no built-in way to do this. However, you could do something like this:
import wx
class CBList(list):
def __init__(self, combobox):
list.__init__(s elf)
self.combobox = combobox
def __setitem__(sel f, key, value):
list.__setitem_ _(self, key, value)
self.combobox.S etString(key, value)
def __delitem__(sel f, key):
list.__delitem_ _(self, key)
self.combobox.D elete(key)
def append(self, value):
list.append(sel f, value)
self.combobox.A ppend(value)
class MyFrame(wx.Fram e):
def __init__(self, parent, id, title):
wx.Frame.__init __(self, parent, id, title)
cb = wx.ComboBox(sel f, -1)
choices = CBList(cb)
choices.append( 'test 1')
choices.append( 'test 2')
choices[0] = 'replace test 1'
del choices[1]
if __name__ == '__main__':
app = wx.PySimpleApp( )
frame = MyFrame(None, -1, 'test')
frame.Show(True )
app.MainLoop ()
Regards,
Cliff
--
Cliff Wells <cl************ @comcast.net>