Reputation: 29178
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)
self.listContainer2 = wx.ListCtrl(item, style=wx.LC_REPORT)
self.listContainer2.InsertColumn(0, 'Column1', width=250)
self.listContainer2.InsertColumn(1, 'Column2', width=150)
self.listContainer2.InsertColumn(2, 'Column3')
m_pnl.AddFoldPanelWindow(item, self.listContainer2)
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()
Upvotes: 0
Views: 330
Reputation: 3177
I see two issues with your example. First, the columns will not show in normal list mode of wx.ListCtrl
. Set the LC_REPORT
style as follows:
self.listContainer = wx.ListCtrl(item, style=wx.LC_REPORT)
Secondary, there is no proper layouting/sizing happening here.
# ...
panel = MyPanel(frame)
# Add sizer information for the scrolled panel
szmain = wx.BoxSizer(wx.VERTICAL)
szmain.Add(panel.pnl, 1, wx.EXPAND|wx.ALL, 4)
panel.SetSizer(szmain)
By applying these changes on wxPython classic 3.0.2 (MSW) at least the controls are layouted so that they fill the frame.
Upvotes: 2