===== Original Message From "Chris Barker" <Chris.Barker@noaa.gov> =====
shuoyang wrote:First of all, thank you all and espeically pythonogolist for the beautiful
solution using lambda, not to mention the cool name (lambda
pseudo-closures).
Pythonologist's solution worked perfectly and is the most elegant.
But prior to his solution, I had managed to get it to work like this,
taking
advantage of the fact of manually assigning the index of the list to the
button's ID, and then later in OnClick(self, event), extract the button's
ID(and also the index to the value of the list to be removed) from
event.getId().Like this:
# this button's ID is the index of the element in the list
sizer.add(button(panel, i, "mybutton with index %d" % i))Careful here. I think you want wxWindow id's to be unique, hence
wxNewID(). Doing this, your ids could clash with who knows what other
wxWindows in the system. I'm not sure what could happen, but I think
it's a no no. That's why I suggested mapping the id to the index with a
dictionary.
Yea definately. I just wanted to make it work as soon as possible. But you
are definately right. That should be avoided.
John
ยทยทยท
-Chris
--
Christopher Barker, Ph.D.
OceanographerNOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main receptionChris.Barker@noaa.gov
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org