collapsible pane overwrites controls below it

I have a python app using wx that
displayed a grid at the top of the frame, and some static-text controls
in a panel below – working fine with sizers.

Now I’m trying to add a collapsible-pane containing a list control
below the grid and above the static-text controls at the bottom.
However, when the collapsible-pane is expanded, its list control writes
over the static controls below.

Further, if one manually drags down the bottom of the frame ever so
slightly, then the expanded static-text controls seem to immediately
move to below the expanded collapsible-pane, so they’re no longer
overwritten. Then, if the collapsible-pane is subsequently hidden, its
controls disappear but it takes the same screen space as when it was
expanded. I tried giving both the collapsible-pane and its
list-control their own sizers, and nothing changed.

Attached are:

  1. standalone code demonstrating the problem

  2. four snapshots showing the frame with:

– A. the hidden collapsible-pane (‘pane collapsed.jpg’)

– B. the expanded collapsible-pane (‘pane expanded.jpg’) [Look at
the very bottom of the frame; shows bottom panel overwritten.]

– C. the expanded collapsible-pane, but after the window is manually
enlarged (‘larger window w pane expanded.jpg’)

– D. the enlarged window, after the collapsible-pane has then been
hidden (‘larger window w pane collapsed.jpg’)

  1. How can I keep the expanded collapsible pane from overwriting the
    controls below it?

  2. How can I force the collapsible pane to take only the expected
    amount of space?

I’ve looked at all the sizer tutorials, etc., and don’t understand
what’s happening or how to resolve it.

I would GREATLY appreciate help on this! Thanks in advance …

collapsible pane problems 2.py (2.67 KB)

larger window w pane collapsed.jpg

larger window w pane expanded.jpg

pane collapsed.jpg

pane expanded.jpg

Hi!

I have a python app using wx that displayed a grid at the top of the frame,
and some static-text controls in a panel below -- working fine with sizers.

Now I'm trying to add a collapsible-pane containing a list control below the
grid and above the static-text controls at the bottom. However, when the
collapsible-pane is expanded, its list control writes over the static
controls below.

Further, if one manually drags down the bottom of the frame ever so
slightly, then the expanded static-text controls seem to immediately move to
below the expanded collapsible-pane, so they're no longer overwritten.
Then, if the collapsible-pane is subsequently hidden, its controls disappear
but it takes the same screen space as when it was expanded. I tried giving
both the collapsible-pane and its list-control their own sizers, and nothing
changed.

Attached are:
1. standalone code demonstrating the problem
2. four snapshots showing the frame with:
-- A. the hidden collapsible-pane ('pane collapsed.jpg')
-- B. the expanded collapsible-pane ('pane expanded.jpg') [Look at the
very bottom of the frame; shows bottom panel overwritten.]
-- C. the expanded collapsible-pane, but after the window is manually
enlarged ('larger window w pane expanded.jpg')
-- D. the enlarged window, after the collapsible-pane has then been hidden
('larger window w pane collapsed.jpg')

1. How can I keep the expanded collapsible pane from overwriting the
controls below it?
2. How can I force the collapsible pane to take only the expected amount of
space?

I've looked at all the sizer tutorials, etc., and don't understand what's
happening or how to resolve it.
I would GREATLY appreciate help on this! Thanks in advance ....
import sys, wx
import wx.grid
import wx.lib.mixins.listctrl as listmix

class TestListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
   def __init__(self, parent, ID, pos=wx.DefaultPosition,
                #size=wx.DefaultSize, style=0):
                size=(400,400), style=0):
       wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
       listmix.ListCtrlAutoWidthMixin.__init__(self)

label1 = "SHOW Collapsible Pane"
label2 = "HIDE Collapsible Pane"

class GuestDisplay(wx.Frame):
   def __init__(self, parent, id, title):
       wx.Frame.__init__(self, parent, id, title, size=wx.DefaultSize)

       # set up the top level panel and its sizer
       panel = wx.Panel(self, -1)
       vbox = wx.BoxSizer(wx.VERTICAL)
       panel.SetSizer(vbox)

       # ONE -- at the top of the panel is a grid
       self.grid = wx.grid.Grid(panel, -1)
       self.grid.CreateGrid(20,20)
       vbox.Add(self.grid, 8, wx.EXPAND | wx.ALL, 0)

       # TWO -- next in the panel is a collapsible pane showing a list
       self.cp = cp = wx.CollapsiblePane(panel, label=label1,
style=wx.CP_DEFAULT_STYLE)
       vbox.Add(cp, 0, wx.GROW|wx.ALL, 0)
       self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnPaneChanged, cp)
       self.hist = TestListCtrl(cp.GetPane(), -1,
                        style=wx.LC_REPORT | wx.BORDER_NONE |
wx.LC_EDIT_LABELS | wx.LC_SORT_ASCENDING )
       self.PopulateList(self.hist)

       # THREE -- at the bottom of the main panel is a child panel with
various items
       panelC = wx.Panel(panel, -1)
       st2 = wx.StaticText(panelC, -1, 'FROM BOTTOM PANEL')
       st2.SetForegroundColour("RED")
       vbox.Add(panelC, 0, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
       vbox.Add((-1, 5))

       self.grid.AutoSize()
       self.Show(True)

   def OnPaneChanged(self, evt=None):
       self.Layout()
       # also change the labels
       if self.cp.IsExpanded():
           self.cp.SetLabel(label2)
       else:
           self.cp.SetLabel(label1)

self.Layout() is being called on the frame (which doesn't have a
sizer). If you change this to calling Layout() on the panel (change
panel to self.panel so you can call it- ie. self.panel.Layout().) then
it will work. Personally, I'd add a sizer to the frame, then add the
panel to that instead of directly on the frame, because I think that
makes it easier to manage sizers. You'll just have to workout the
window size, because it starts at the collapsed size on XP.

   def PopulateList(self, hist):
       # column headers
       hist.InsertColumn(0, "Status")
       hist.InsertColumn(1, "Start time", wx.LIST_FORMAT_RIGHT)
       hist.InsertColumn(2, "Duration")
       # dummy data just for example
       index = hist.InsertStringItem(sys.maxint, "UP")
       hist.SetStringItem(index, 1, "Dec-12 06:14:02 AM")
       hist.SetStringItem(index, 2,"8:47:13 hours")
       hist.SetColumnWidth(0, wx.LIST_AUTOSIZE)
       hist.SetColumnWidth(1, wx.LIST_AUTOSIZE)
       hist.SetColumnWidth(2, wx.LIST_AUTOSIZE)

app = wx.App()
display = GuestDisplay(None, -1, "My Display")
app.MainLoop()

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Thanks,
Scott

···

On Fri, Jan 2, 2009 at 5:12 PM, BobAtTP <BobAtTP@comcast.net> wrote: