AGW Logo

agw_title foldpanelbar

FoldPanelBar is a control that contains multiple panels, which can be expanded or collapsed.

description Description

The FoldPanelBar is a control that contains multiple panels (of type FoldPanelItem) that can be expanded or collapsed. The captionbar of the FoldPanelBar can be customized by setting it to a horizontal gradient style, vertical gradient style, a single colour, a rectangle or filled rectangle. The FoldPanel items can be collapsed in place or to the bottom of the control. wx.Window derived controls can be added dynamically, and separated by separator lines.

How does it work

The internals of the FoldPanelBar is a list of FoldPanelItem objects. Through the reference of FoldPanel these panels can be controlled by adding new controls to a FoldPanel or adding new FoldPanels to the FoldPanelBar.

The CaptionBar fires events to the parent (container of all panel items) when a sub-panel needs resizing (either folding or expanding). The fold or expand process is simply a resize of the panel so it looks like all controls on it are gone. All controls are still child of the FoldPanel they are located on. If they don’t handle the event (and they won’t) then the owner of the FoldPanelBar gets the events.

This is what you need to handle the controls. There isn’t much to it just a lot of calculations to see what panel belongs where. There are no sizers involved in the panels, everything is purely x-y positioning.

What can it do and what not?

  1. What it can do:
    • Run-time addition of panels (no deletion just yet);
    • Run time addition of controls to the panel (it will be resized accordingly);
    • Creating panels in collapsed mode or expanded mode;
    • Various modes of caption behaviour and filling to make it more appealing;
    • Panels can be folded and collapsed (or all of them) to allow more space.
  2. What it cannot do:
    • Selection of a panel like in a listctrl;
    • Dragging and dropping the panels;
    • Re-ordering the panels (not yet).

usage Usage

Usage example:

import wx
import wx.lib.agw.foldpanelbar as fpb

class MyFrame(wx.Frame):

    def __init__(self, parent):

        wx.Frame.__init__(self, parent, -1, "FoldPanelBar Demo")

        text_ctrl = wx.TextCtrl(self, -1, size=(400, 100), style=wx.TE_MULTILINE)

        panel_bar = fpb.FoldPanelBar(self, -1, agwStyle=fpb.FPB_HORIZONTAL|fpb.FPB_DEFAULT_STYLE)

        fold_panel = panel_bar.AddFoldPanel("Thing")
        thing = wx.TextCtrl(fold_panel, -1, size=(400, -1), style=wx.TE_MULTILINE)

        panel_bar.AddFoldPanelWindow(fold_panel, thing)

        main_sizer = wx.BoxSizer(wx.HORIZONTAL)
        main_sizer.Add(text_ctrl, 1, wx.EXPAND)
        main_sizer.Add(panel_bar, 0, wx.EXPAND)

# our normal wxApp-derived class, as usual

app = wx.PySimpleApp()

frame = MyFrame(None)


This code snippet can be downloaded, see this example script.


Some of the AGW snippets of code in the documentation use images and external files (to create bitmaps or access external data). As these files are not provided in these snippets, you should make the approriate modifications to the code to actually run it.

platforms Supported Platforms

FoldPanelBar is supported on the following platforms:
  • Windows (Verified on Windows XP, 2000)
  • Linux/Unix (GTK2) (Thanks to Toni Brkic and Robin Dunn)
  • Mac OSX (Thanks to Robin Dunn for the CaptionBar size patch)

styles Window Styles

This class supports the following window styles:

Window styles for foldpanelbar
Window Styles Hex Value Description
FPB_SINGLE_FOLD 0x1 Single fold forces other panels to close when they are open, and only opens the current panel. This will allow the open panel to gain the full size left in the client area.
FPB_COLLAPSE_TO_BOTTOM 0x2 All panels are stacked to the bottom. When they are expanded again they show up at the top.
FPB_EXCLUSIVE_FOLD 0x4 FPB_SINGLE_FOLD style plus the panels will be stacked at the bottom.
FPB_HORIZONTAL 0x8 FoldPanelBar will be horizontal.
FPB_VERTICAL 0x10 FoldPanelBar will be vertical.

events Events Processing

This class processes the following events:

Events processing for foldpanelbar
Event Name Description
EVT_CAPTIONBAR The user has pressed the caption bar: FoldPanelBar will either expand or collapse the underlying panel.

license License And Version

FoldPanelBar is distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 17 Sep 2011, 23.00 GMT

Version 0.5

Module author: Andrea Gavana <>

hierarchy Inheritance Diagram

Inheritance diagram for module: foldpanelbar

Inheritance diagram of foldpanelbar.CaptionBar, foldpanelbar.CaptionBarEvent, foldpanelbar.CaptionBarStyle, foldpanelbar.FoldPanelBar, foldpanelbar.FoldPanelItem, foldpanelbar.FoldWindowItem

svn_main SVN Revisions

A graphical representation of the SVN commits in the last year.

Click on any date in the picture to jump to that particular revision page, containing information about committers, log messages and SVN diffs.


Revision Graph For foldpanelbar

2to3 Python 3 Issues (via 2to3)

No issues have been detected by