How to do FoldPanelBar inside ScrollPanel in wxPython?

I tried to do a collapsible FoldPanelBar inside of a ScrollPanel. But it is not loading the contents of the FoldPanelBar. The list control UI inside the fold panel is not even loading. I tried replacing with a regular panel, but the result is the same. Could you please let me know if I am missing something here

import wx
from wx.lib import scrolledpanel
import wx.lib.agw.foldpanelbar as fpb
class MyPanel(wx.lib.scrolledpanel.ScrolledPanel):

    def __init__(self, parent):
        wx.lib.scrolledpanel.ScrolledPanel.__init__(self, parent=parent, size=parent.GetSize(), style = wx.ALL|wx.EXPAND)
        self.SetAutoLayout(1)
        self.SetupScrolling()

        csStyle = fpb.CaptionBarStyle()
        csStyle.SetFirstColour(wx.Colour(190, 190, 190, 255))
        csStyle.SetSecondColour(wx.Colour(167, 232, 146, 255))
        csStyle.SetCaptionFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.BOLD))

        m_pnl = fpb.FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
                            fpb.FPB_VERTICAL)

        item = m_pnl.AddFoldPanel("Set 1", collapsed=True, cbstyle=csStyle)

        self.listContainer = wx.ListCtrl(item)
        self.listContainer.InsertColumn(0, 'Column1', width=250)
        self.listContainer.InsertColumn(1, 'Column2', width=150)
        self.listContainer.InsertColumn(2, 'Column3')

        m_pnl.AddFoldPanelWindow(item, self.listContainer)
        btnGo = wx.Button(item, wx.ID_ANY, "Go", size=(50,-1))
        m_pnl.AddFoldPanelWindow(item, btnGo)

        item = m_pnl.AddFoldPanel("Set 2", collapsed=True, cbstyle=csStyle)
        m_pnl.AddFoldPanelWindow(item, self.listContainer)
        self.pnl = m_pnl
if __name__ == '__main__':
    app = wx.App(False)
    frame = wx.Frame(None, size=(650, 400), style=wx.DEFAULT_FRAME_STYLE)
    panel = MyPanel(frame)
    frame.Show() 
app.MainLoop().

I think it is something related to frame and panel association. But I can’t tell. Anything looks off here?

All your controls certainly are there, but you’re not using any
sizers, so all of the controls are sized at 20 pixels square and are
piled on top of one another at the upper left of the panel.
You should go do some reading about sizers. They will make your
life much easier.

···

Ajay wrote:

      I tried to do a collapsible FoldPanelBar inside of a

ScrollPanel. But it is not loading the contents of the
FoldPanelBar. The list control UI inside the fold panel is not
even loading. I tried replacing with a regular panel, but the
result is the same. Could you please let me know if I am
missing something here

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

Thanks for your time. Could you please check the attached file which has the sizers in place. It loads up fine, but when I expand the fold panels, the scroll bars are not appearing. Not sure what I am missing here.

FoldPanelBarNotScrolling.py (2.11 KB)

Ajay wrote:

Thanks for your time. Could you please check the attached file which
has the sizers in place. It loads up fine, but when I expand the fold
panels, the scroll bars are not appearing. Not sure what I am missing
here.

The problem here is that ScrolledPanel and ScrolledWindow are not set up
to handle content that dynamically changes in size. It locks in to its
"virtual size" at initialization time, and does not monitor and resize
events.

Perhaps someone else has a better solution for this.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.