wxPython: changing entries of a HtmlListBox

KvS keesvanschaik at gmail.com
Wed May 24 22:25:46 EDT 2006


Hi all,

a question wrt renewing the entries in a wx.HtmlListBox, I don't
understand how to do it.

I have some global variable containing a list:

gl_NAWList=["Bet","Dik"]

then I create a subclass of wx.HtmlListBox as described in the wxPython
demo:

class MyHtmlListBox(wx.HtmlListBox):
	def OnGetItem(self, n):
		return gl_NAWList[n]

and this works well after putting an instance called "hlb" of it in a
frame etc. Now I want to change the entries in hlb and I thought I
should simply be able to call the following function (bound to a button
click, "self" refers to the frame on which both teh button and hlb are
placed):

def klik(self, event):
		gl_NAWList=["Boy","Boy"]
		#print "gl_NAWList = ",gl_NAWList
		self.hlb.SetItemCount(len(gl_NAWList))
		self.Refresh()

but that doesn't seem to be working in the sense that the entries are
still "Bet" and "Dik". Also if I change this code to completely destroy
teh existing hlb and create a new instance it's not working. As will
probably be painfully clear ;) I just started playing a bit around with
wxPython. Any hints would be very much appreciated!

Thanks, Kees




More information about the Python-list mailing list