I have a panel of pictures in a flexgridsizer, where each
picture is in a boxsizer as so:
self.fgs = wxFlexGridSizer(2, 4, 10, 10)
wxInitAllImageHandlers()
then I add each picture to the flexgridsizer
for pic in self.pics:
im = Image.open(StringIO.StringIO(pic))
im = im.resize((128, 128))
im = im.convert("RGB")
wxim = wxEmptyImage(im.size[0], im.size[1] )
wxim.SetData( im.tostring() )
image = wxBitmapFromImage(wxim)
box = wxBoxSizer(wxVERTICAL)
box.AddWindow(wxStaticBitmap(self, -1, image),
0, wxALIGN_CENTRE|wxALL, 5)
text = wxStaticText(self, -1, "a test picture")
box.AddWindow(text, 0, wxALIGN_CENTRE|wxALL, 5)
self.fgs.AddSizer(box, 0, wxALIGN_CENTRE, 5)
I want to be able to add and remove pictures from the flexgrid
sizer:
Here I add a boxsizer with a picture in it to the flexgridsizer:
box = wxBoxSizer(wxVERTICAL)
box.AddWindow(wxStaticBitmap(self, -1,
image), 0, wxALIGN_CENTRE|wxALL, 5)
text = wxStaticText(self, -1, "some text")
box.AddWindow(text, 0, wxALIGN_CENTRE|wxALL,
5)
self.fgs.AddSizer(box, 0,
wxALIGN_CENTRE|wxALL, 5)
self.fgs.RecalcSizes()
My question is, how do I remove the boxsizers if I want to
delete a picture? In the following test, I remove two picture,
because for debugging purposes I know there are two pictures
present:
self.fgs.Remove(1)
self.fgs.Remove(0)
self.fgs.RecalcSizes()
self.Layout()
self.Refresh()
I have some buttons under the pictures which move up as pictures
are deleted. When the above is executed and the two pictures
are removed, the buttons move up to where the pictures used to
be, but the pictures remain in the background and the buttons
aren't refreshed. How can I make it so the pictures go away
completely when I remove one or more? and how can I find out
how many sizers are in the flexgridsizer? also, since I am new
at this, is there a better way to accomplish what I'm doing? Thanks in advance!
Sameer