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

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))
        title.SetForegroundColour("blue")

        self.cp = cp = PCP.PyCollapsiblePane(panel, label=label1,
                                             style=wx.CP_DEFAULT_STYLE|wx.CP_NO_TLW_RESIZE)

        self.MakePaneContent(cp.GetPane())

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

        panel.SetSizer(sizer)
        sizer.Layout()


    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.AddGrowableCol(1)
        addrSizer.Add(nameLbl, 0,
                      wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(name, 0, wx.EXPAND)
        addrSizer.Add(addrLbl, 0,
                      wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
        addrSizer.Add(addr1, 0, wx.EXPAND)
        addrSizer.Add((5,5))
        addrSizer.Add(addr2, 0, wx.EXPAND)

        addrSizer.Add(cstLbl, 0,
                      wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)

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

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


# our normal wxApp-derived class, as usual

app = wx.PySimpleApp()

frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()

app.MainLoop()

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

Note

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 <andrea.gavana@gmail.com>


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.

pycollapsiblepane

Revision Graph For pycollapsiblepane


2to3 Python 3 Issues (via 2to3)

No issues have been detected by 2to3.py.