AGW Logo

agw_title pycollapsiblepane

PyCollapsiblePane is a container with an embedded button-like control which can be used by the user to collapse or expand the pane’s contents.

description Description

A collapsible pane is a container with an embedded button-like control which can be used by the user to collapse or expand the pane’s contents. Once constructed you should use the GetPane function to access the pane and add your controls inside it (i.e. use the window returned from GetPane as the parent for the controls which must go in the pane, not the PyCollapsiblePane itself!).


Note that because of its nature of control which can dynamically (and drastically) change its size at run-time under user-input, when putting PyCollapsiblePane inside a wx.Sizer you should be careful to add it with a proportion value of zero; this is because otherwise all other windows with non-null proportion values would automatically get resized each time the user expands or collapse the pane window resulting usually in a weird, flickering effect.

usage Usage

Usage example:

import wx
import wx.lib.agw.pycollapsiblepane as PCP

class MyFrame(wx.Frame):

    def __init__(self, parent):

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

        panel = wx.Panel(self)

        title = wx.StaticText(panel, label="PyCollapsiblePane")
        title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))

        self.cp = cp = PCP.PyCollapsiblePane(panel, label=label1,


        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(title, 0, wx.ALL, 25)
        sizer.Add(cp, 0, wx.RIGHT|wx.LEFT|wx.EXPAND, 25)


    def MakePaneContent(self, pane):
        ''' Just makes a few controls to put on `PyCollapsiblePane`. '''

        nameLbl = wx.StaticText(pane, -1, "Name:")
        name = wx.TextCtrl(pane, -1, "");

        addrLbl = wx.StaticText(pane, -1, "Address:")
        addr1 = wx.TextCtrl(pane, -1, "");
        addr2 = wx.TextCtrl(pane, -1, "");

        cstLbl = wx.StaticText(pane, -1, "City, State, Zip:")
        city  = wx.TextCtrl(pane, -1, "", size=(150,-1));
        state = wx.TextCtrl(pane, -1, "", size=(50,-1));
        zip   = wx.TextCtrl(pane, -1, "", size=(70,-1));

        addrSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
        addrSizer.Add(nameLbl, 0,
        addrSizer.Add(name, 0, wx.EXPAND)
        addrSizer.Add(addrLbl, 0,
        addrSizer.Add(addr1, 0, wx.EXPAND)
        addrSizer.Add(addr2, 0, wx.EXPAND)

        addrSizer.Add(cstLbl, 0,

        cstSizer = wx.BoxSizer(wx.HORIZONTAL)
        cstSizer.Add(city, 1)
        cstSizer.Add(state, 0, wx.LEFT|wx.RIGHT, 5)
        addrSizer.Add(cstSizer, 0, wx.EXPAND)

        border = wx.BoxSizer()
        border.Add(addrSizer, 1, wx.EXPAND|wx.ALL, 5)

# 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.

styles Window Styles

This class supports the following window styles:

Window styles for pycollapsiblepane
Window Styles Hex Value Description
CP_NO_TLW_RESIZE 0x2 By default PyCollapsiblePane resizes the top level window containing it when its own size changes. This allows to easily implement dialogs containing an optionally shown part, for example, and so is the default behaviour but can be inconvenient in some specific cases – use this flag to disable this automatic parent resizing then.
CP_GTK_EXPANDER 0x4 Uses a GTK expander instead of a button.
CP_USE_STATICBOX 0x8 Uses a wx.StaticBox around PyCollapsiblePane.
CP_LINE_ABOVE 0x10 Draws a line above PyCollapsiblePane.

events Events Processing

This class processes the following events:

Events processing for pycollapsiblepane
Event Name Description
EVT_COLLAPSIBLEPANE_CHANGED The user showed or hid the collapsible pane.

license License And Version

PyCollapsiblePane is distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 17 Aug 2011, 15.00 GMT

Version 0.4

Module author: Andrea Gavana <>

hierarchy Inheritance Diagram

Inheritance diagram for module: pycollapsiblepane

Inheritance diagram of pycollapsiblepane.GTKExpander, pycollapsiblepane.PyCollapsiblePane

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 pycollapsiblepane

2to3 Python 3 Issues (via 2to3)

No issues have been detected by