[wxPython] wxSizer: Remove() followed by Add() fails with Win98

When running the code below with wxGTK (Alpha with Tru64), everything
looks OK. When running the same code on Win98, the lower button ends up
in the wrong position (top left hand corner).

Change the "if (0)" statement next to "TEST 2" to "if (1)", and the
button is positioned correctly.

My conclusion: On Win98 the sequence of calls

      panel_szr.Remove(mbr_win)
      ...
      panel_szr.Add(mbr_win, 0)

is not handled properly unless a panel_szr.Fit() statement is inserted.

That same sequence of calls works fine on Win98 even without the Fit()
if mbr_win is not destroyed and re-created. To me it looks like some
sizer-internal settings are not cleared correctly when calling
Remove().

Ralf

from wxPython.wx import *

class MyApp(wxApp):

  def OnInit(self):
    main_frame = wxFrame(NULL, -1, 'Main Frame', size = wxSize(200, 200))
    scr_win = wxScrolledWindow(main_frame, -1, style = wxSUNKEN_BORDER)
    (W, H) = (400, 400)
    scr_win.SetScrollbars(20, 20, (W + 19) / 20, (H + 19) / 20)

    panel_win = wxPanel(scr_win, -1, style = wxSIMPLE_BORDER)
    panel_szr = wxBoxSizer(wxVERTICAL)
    panel_win.SetAutoLayout(true)
    panel_win.SetSizer(panel_szr)

    ctbox_win = wxPanel(panel_win, -1)
    ctbox_szr = wxBoxSizer(wxHORIZONTAL)
    ctbox_win.SetAutoLayout(true)
    ctbox_win.SetSizer(ctbox_szr)

    view_btn = wxButton(ctbox_win, -1, 'V')
    H = view_btn.GetSize().height
    view_btn.SetSize(wxSize(H, H))
    ctbox_szr.Add(view_btn, 0, wxRIGHT, 10)
    cap = wxStaticText(ctbox_win, -1, 'List of something')
    ctbox_szr.Add(cap, 0, wxALIGN_CENTER_VERTICAL)

    ctbox_szr.Fit(ctbox_win)
    panel_szr.Add(ctbox_win, 0, wxALL, 10)

    mbr_win = wxPanel(panel_win, -1)
    mbr_szr = wxBoxSizer(wxVERTICAL)
    mbr_win.SetAutoLayout(true)
    mbr_win.SetSizer(mbr_szr)

    btn = wxButton(mbr_win, -1, 'Button')
    mbr_szr.Add(btn, 0, wxALL, 10)
    mbr_szr.Fit(mbr_win)
    panel_szr.Add(mbr_win, 0)

    panel_szr.Fit(panel_win)

    if (1): # TEST1
      panel_szr.Remove(mbr_win)
      mbr_win.Destroy()

      if (0): # TEST2
        panel_szr.Fit(panel_win)

      if (1): # TEST3
        mbr_win = wxPanel(panel_win, -1)
        mbr_szr = wxBoxSizer(wxVERTICAL)
        mbr_win.SetAutoLayout(true)
        mbr_win.SetSizer(mbr_szr)

        btn = wxButton(mbr_win, -1, 'Button')
        mbr_szr.Add(btn, 0, wxALL, 10)
        mbr_szr.Fit(mbr_win)
        panel_szr.Add(mbr_win, 0)

      panel_szr.Fit(panel_win)

    main_frame.Show(true)
    self.SetTopWindow(main_frame)
    return true

app = MyApp(0)
app.MainLoop()

--== Sent via Deja.com http://www.deja.com/ ==--
Before you buy.