Replacing Window in a BoxSizer

Hi All,

I have hit a roadblock and am looking for some help/ideas..

In my app, there is a two-pane interface (using a splitter window),
the left pane has a tree and the right pane contents change according
to the node selected on the left.

The rightpane has a title panel that tells what folder is current
selected. The way I have designed the rightpane, the title panel is
always there and I call SetLabel() to alter the title.

The second item in the rightpane sizer is a panel that changes
contents. Each node type has its panel type, so if I have 3 different
node types, I have 3 totally different panel types with different
widgets and data, each panel type being a singleton).

I tried doing the following:

    def _createContentPanel(self, pnlContent):
        if not self.pnlContentCalled:
            self.pnlContentCalled = True
            self.box.Add(pnlContent, 1, wx.EXPAND|wx.ALL, 0)
        else:
            #sizerItem = self.box.GetItem(1)
            #sizerItem.SetWindow(pnlContent)
            self.box.Remove(1)
            self.box.Insert(1, pnlContent, 1, wx.EXPAND|wx.ALL, 0)
            self.Layout()
        self.box.Layout()
        self.Refresh()

1. self.box = wx.BoxSizer(wx.VERTICAL)
2. The 0th item in self.box is the title panel

(commented lines indicate my other desperate attempts.
sizerItem.RemoveWindows works but I can not use it as I end up doing
what I am trying to avoid...recreate the panels each time)

The code above, I had hoped would replace the previous window in the
size with my new panel. The reason I am doing it this way to minimize
creation of new widgets.

How do I replace the content panel in the sizer?

Thank you,
-Kartic

Can you simply add the new control, and hide the old one, using wx.Sizer.Show(window, False)? This way, if the user navigates to the same node again, just re-show that control and hide the others.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

···

On Aug 29, 2005, at 3:36 PM, Kartic Krish wrote:

The code above, I had hoped would replace the previous window in the
size with my new panel. The reason I am doing it this way to minimize
creation of new widgets.

Ed,

That seems to be a good idea and should work well for me because I
anyway create the panels at some point. Let me try that out.

Thank you,
-Kartic

···

On 8/29/05, Ed Leafe <ed@leafe.com> wrote:

On Aug 29, 2005, at 3:36 PM, Kartic Krish wrote:

> The code above, I had hoped would replace the previous window in the
> size with my new panel. The reason I am doing it this way to minimize
> creation of new widgets.

     Can you simply add the new control, and hide the old one, using
wx.Sizer.Show(window, False)? This way, if the user navigates to the
same node again, just re-show that control and hide the others.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org