phoenix_title wx.lib.agw.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

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 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.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
        title.SetForegroundColour("blue")

        self.cp = cp = PCP.PyCollapsiblePane(panel, label="Some Data",
                                             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.App(0)

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

app.MainLoop()

Window Styles

This class supports the following window styles:

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 StaticBox around PyCollapsiblePane.

CP_LINE_ABOVE

0x10

Draws a line above PyCollapsiblePane.

Events Processing

This class processes the following events:

Event Name

Description

EVT_COLLAPSIBLEPANE_CHANGED

The user showed or hid the collapsible pane.

License And Version

PyCollapsiblePane is distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 19 Dec 2012, 21.00 GMT

Version 0.5

class_summary Classes Summary

GTKExpander

A GTKExpander allows the user to hide or show its child by clicking on an expander

PyCollapsiblePane

PyCollapsiblePane is a container with an embedded button-like control which