Thanks for the reply. It is helpful to know that I can compare the button
objects directly with the event triggered button.
I'm just surprised that there isn't a more elegant solution that I know of,
given the elegance of python.
Somehow I'm almost certain there is a better way, is there something like a
event manager that would help with this sort of things? I mean, button
onclick updates an python built-in list must happen all the time. There
must be some mechanism that's just right for this kind of things.
John
===== Original Message From "Mike C. Fletcher" <mcfletch@rogers.com> =====
Following is by no means an elegant solution, but it's the first one
that pops into my mind...shuoyang wrote:
Hi dear wxPython users:
I am pretty new to wxPython, and find it amazing, not to mention powerful!
But I've run into one problem, I've read thru the tutorials, but can't seem
to
figure out how to do this:
#I have a list of things:
MyList = [elem1,elem2,....]itemMapping = # MyList[i] is represented by control with ID
itemMapping[i]#then I have loop:
for v in MyList:
make static text with v
make a button to delete v from MyList, call OnClickitemMapping.append( (button,text) )
def OnClick(self,event)
need to know the index of v to delete v from MyList, but how?for i, (object,(button,text)) in enumerate( zip(MyList, itemMapping)):
if button == event.GetEventObject(): # might be GetId(), been a while
del MyList[i]
# remove controls from parent here
del itemMapping[i]
break # all further indices are messed up anyway...Since python list is not object in wxPython, i don't think the event
parameter
···
in OnClick would help. Can anyone offer a hint? Thanks!
JohnIn real-world code I'd likely make the model-view split a little more
elegant and less fragile, but then I'm somewhat obsessive about those
kinds of things.HTH,
Mike_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org