Problem with storing widgets in a list

Daniel Gee wrote:

(re-post because the last message was turned into gibberish by, i think, using utf-8)

I'm trying to make a tile "engine" for a game, and my current design is to have a 2d list of panels (which do the custom drawing) and then place the panels into an appropriate grid sizer. However, when I try to access the panels within the 2d list then either the wrong panels are accessed or the panel data isn't changed so they don't change their image at all.

I have an example with buttons. When I press the button marked "button" the button in cell 6,2 changes to "click" not the one in cell 1,2 as intended. Similarly, in an example version where I didn't store the button to a seperate variable first and instead stored it directly into the list of panels, then it didn't ever cause events to trigger at all.

Are wx objects just allergic to python lists or something?

Your self.panels list is not the same "shape" as your grid sizer. Adding a pprint after you create the list shows this:

[[0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0]]

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!