在 wxPython 中展开的 FoldPanelBar 上没有出现滚动条
Scrollbars are not appearing on expanding FoldPanelBar in wxPython
当折叠面板展开时,它会超出框架并且不会出现滚动条。我尝试使用 ScrolledPanel,但没有帮助。知道我在这里缺少什么吗?
import wx
from wx.lib import scrolledpanel
import wx.lib.agw.foldpanelbar as fpb
import wx.lib.scrolledpanel as sp
class MyPanel(sp.ScrolledPanel):
def __init__(self, parent):
sp.ScrolledPanel.__init__(self, parent=parent, size=parent.GetSize(), style = wx.ALL|wx.EXPAND)
#self.SetAutoLayout(1)
self.SetupScrolling()
##self.boxSizer = wx.BoxSizer(wx.VERTICAL)###
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, style=wx.LC_REPORT)
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)
btnAutoFix = wx.Button(item, wx.ID_ANY, "Go", size=(50,-1))
m_pnl.AddFoldPanelWindow(item, btnAutoFix)
###self.boxSizer.Add(m_pnl)##
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
##self.SetSizer(self.boxSizer)###
if __name__ == '__main__':
app = wx.App(False)
frame = wx.Frame(None, size=(650, 400), style=wx.DEFAULT_FRAME_STYLE)
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)
frame.Show()
app.MainLoop()
不要使用 FoldPanelBar
的默认大小。出于某种原因,它似乎使小部件以愚蠢的方式运行。如果指定大小,滚动条会正确显示。
import wx
import wx.lib.agw.foldpanelbar as fpb
import wx.lib.scrolledpanel as scrolled
class MyPanel(scrolled.ScrolledPanel):
def __init__(self, parent):
scrolled.ScrolledPanel.__init__(self, parent=parent,
size=parent.GetSize(),
style = wx.ALL|wx.EXPAND)
#self.SetAutoLayout(1)
self.SetupScrolling()
self.boxSizer = wx.BoxSizer(wx.VERTICAL)
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, (600,800),
fpb.FPB_VERTICAL)
item = m_pnl.AddFoldPanel("Set 1", collapsed=True, cbstyle=csStyle)
self.listContainer = wx.ListCtrl(item, style=wx.LC_REPORT)
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)
btnAutoFix = wx.Button(item, wx.ID_ANY, "Go", size=(50,-1))
m_pnl.AddFoldPanelWindow(item, btnAutoFix)
self.boxSizer.Add(m_pnl)
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
self.SetSizer(self.boxSizer)
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='Test')
panel = MyPanel(self)
self.Show()
if __name__ == '__main__':
app = wx.App(False)
frame = MainFrame()
app.MainLoop()
您可能会考虑 submitting a bug 为此到 wxPython 项目。
当折叠面板展开时,它会超出框架并且不会出现滚动条。我尝试使用 ScrolledPanel,但没有帮助。知道我在这里缺少什么吗?
import wx
from wx.lib import scrolledpanel
import wx.lib.agw.foldpanelbar as fpb
import wx.lib.scrolledpanel as sp
class MyPanel(sp.ScrolledPanel):
def __init__(self, parent):
sp.ScrolledPanel.__init__(self, parent=parent, size=parent.GetSize(), style = wx.ALL|wx.EXPAND)
#self.SetAutoLayout(1)
self.SetupScrolling()
##self.boxSizer = wx.BoxSizer(wx.VERTICAL)###
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, style=wx.LC_REPORT)
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)
btnAutoFix = wx.Button(item, wx.ID_ANY, "Go", size=(50,-1))
m_pnl.AddFoldPanelWindow(item, btnAutoFix)
###self.boxSizer.Add(m_pnl)##
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
##self.SetSizer(self.boxSizer)###
if __name__ == '__main__':
app = wx.App(False)
frame = wx.Frame(None, size=(650, 400), style=wx.DEFAULT_FRAME_STYLE)
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)
frame.Show()
app.MainLoop()
不要使用 FoldPanelBar
的默认大小。出于某种原因,它似乎使小部件以愚蠢的方式运行。如果指定大小,滚动条会正确显示。
import wx
import wx.lib.agw.foldpanelbar as fpb
import wx.lib.scrolledpanel as scrolled
class MyPanel(scrolled.ScrolledPanel):
def __init__(self, parent):
scrolled.ScrolledPanel.__init__(self, parent=parent,
size=parent.GetSize(),
style = wx.ALL|wx.EXPAND)
#self.SetAutoLayout(1)
self.SetupScrolling()
self.boxSizer = wx.BoxSizer(wx.VERTICAL)
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, (600,800),
fpb.FPB_VERTICAL)
item = m_pnl.AddFoldPanel("Set 1", collapsed=True, cbstyle=csStyle)
self.listContainer = wx.ListCtrl(item, style=wx.LC_REPORT)
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)
btnAutoFix = wx.Button(item, wx.ID_ANY, "Go", size=(50,-1))
m_pnl.AddFoldPanelWindow(item, btnAutoFix)
self.boxSizer.Add(m_pnl)
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
self.SetSizer(self.boxSizer)
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='Test')
panel = MyPanel(self)
self.Show()
if __name__ == '__main__':
app = wx.App(False)
frame = MainFrame()
app.MainLoop()
您可能会考虑 submitting a bug 为此到 wxPython 项目。