> I have a GridBagSizer (sizer) with w x h bottons (one each cell),
> I would like to destroy all buttons to reload them (with different w & h):
> > for row in range(h):
> for c in range(w):
> item = sizer.FindItemAtPosition((row, c))
> if item:
> obj = item.GetWindow()
> sizer.Detach(obj)
> obj.Destroy()
> self.SetSizerAndFit(sizer)
If this is shown with correct indentation then repeatedly setting the same sizer object inside this loop will likely cause problems.
> > for a in range(t):
> button[a] = BitmapButton(self, id=a, bitmap=backImage, size=(xIm, yIm))
> RegisterId(a)
> sizer.Add(button[a], ( a/w, (a-(a/w)*w) ))
> self.Bind(EVT_BUTTON, self.OnButtonClick1, button[a])
> sizer.Fit(self)
> > [complete code on http://sourceforge.net/projects/pmemory/\]
> > A few positions (where I expect buttons) are left empty in Windows,
> while the code works as expected in Linux.
I would try it something like this:
1. Call sizer.Clear(deleteWindows=True)
2. Create a new sizer
3. Add items to the new sizer
4. Call self.SetSizer(newsizer)
5. Call self.Layout()
-- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Thank you very much! The following code works as expected:
sizer.Clear(deleteWindows=True)
sizer = GridBagSizer()
for a in range(t):
button[a] = BitmapButton(self, id=a, bitmap=backImage, size=(xIm, yIm))
RegisterId(a)
sizer.Add(button[a], ( a/w, (a-(a/w)*w) ))
self.Bind(EVT_BUTTON, self.OnButtonClick1, button[a])
# this resizes the sizer (and the frame) to the first button
# otherwise empty rows (columns) are shown with smaller h (w)
if a==0: sizer.Fit(self)
self.SetSizerAndFit(sizer)
self.Layout()
rosros
···
rosros-3@email.it wrote:
Email.it, the professional e-mail, gratis per te: http://www.email.it/f
Sponsor:
Scopri Carta Eureka e realizza i tuoi sogni! Fido fino a 3.000 euro, rate a partire da 20 euro e canone gratis il 1° anno!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7878&d=2-8