AGW Logo

agw_title FoldPanelBar

The FoldPanelBar is a class which can maintain a list of collapsible panels. Once a panel is collapsed, only it’s caption bar is visible to the user. This will provide more space for the other panels, or allow the user to close panels which are not used often to get the most out of the work area.

This control is easy to use. Simply create it as a child for a panel or sash window, and populate panels with AddFoldPanel. Then use the AddFoldPanelWindow to add wx.Window derived controls to the current fold panel. Use AddFoldPanelSeparator to put separators between the groups of controls that need a visual separator to group them together. After all is constructed, the user can fold the panels by double clicking on the bar or single click on the arrow, which will indicate the collapsed or expanded state.

hierarchy Inheritance Diagram

Inheritance diagram for: FoldPanelBar

Inheritance diagram of FoldPanelBar


appearance Control Appearance


FoldPanelBar

FoldPanelBar


method_summary Methods Summary

__init__Default class constructor.
AddFoldPanelAdds a fold panel to the list of panels.
AddFoldPanelSeparatorAdds a separator line to the current fold panel.
AddFoldPanelWindowAdds a wx.Window derived instance to the referenced fold panel.
ApplyCaptionStyleSets the style of the caption bar (CaptionBar) of the fold panel.
ApplyCaptionStyleAllSets the style of all the caption bars of the fold panel.
CollapseCollapses the given fold panel reference, and updates the foldpanel bar.
ExpandExpands the given fold panel reference, and updates the foldpanel bar.
GetCaptionStyleReturns the currently used caption style for the fold panel.
GetCountReturns the number of panels in the FoldPanelBar.
GetFoldPanelReturns the panel associated with the index item.
GetPanelsLengthReturns the length of the panels that are expanded and collapsed.
IsVerticalReturns whether the CaptionBar has default orientation or not.
OnPressCaptionHandles the wx.EVT_CAPTIONBAR event for CaptionBar.
OnSizePanelHandles the wx.EVT_SIZE event for FoldPanelBar.
RedisplayFoldPanelItemsResizes the fold panels so they match the width.
RefreshPanelsFromRefreshes all the panels from given one down to last one.
RepositionCollapsedToBottomRepositions all the collapsed panels to the bottom.

API Class API

class FoldPanelBar(wx.Panel)[source]

The FoldPanelBar is a class which can maintain a list of collapsible panels. Once a panel is collapsed, only it’s caption bar is visible to the user. This will provide more space for the other panels, or allow the user to close panels which are not used often to get the most out of the work area.

This control is easy to use. Simply create it as a child for a panel or sash window, and populate panels with FoldPanelBar.AddFoldPanel(). Then use the FoldPanelBar.AddFoldPanelWindow() to add wx.Window derived controls to the current fold panel. Use FoldPanelBar.AddFoldPanelSeparator() to put separators between the groups of controls that need a visual separator to group them together. After all is constructed, the user can fold the panels by double clicking on the bar or single click on the arrow, which will indicate the collapsed or expanded state.



__init__(parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.NO_BORDER, agwStyle=0)[source]

Default class constructor.

Parameters:
  • parent – the FoldPanelBar parent window;
  • id – an identifier for the control: a value of -1 is taken to mean a default;
  • pos – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;
  • size – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;
  • style – the underlying wx.Panel window style;
  • agwStyle – the AGW-specific FoldPanelBar window style. It can be one of the following bits:


    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 0x4 FoldPanelBar will be horizontal.
    FPB_VERTICAL 0x8 FoldPanelBar will be vertical.


AddFoldPanel(caption='', collapsed=False, foldIcons=None, cbstyle=None)[source]

Adds a fold panel to the list of panels.

Parameters:
  • caption – the caption to be displayed in the associated CaptionBar;
  • collapsed – if set to True, the panel is collapsed initially;
  • foldIcons – an instance of wx.ImageList containing the icons to display next to the caption text;
  • cbstyle – an instance of CaptionBarStyle.

Note

The FoldPanel item which is returned, can be used as a reference to perform actions upon the fold panel like collapsing it, expanding it, or deleting it from the list. Use this foldpanel to add windows to it.

See also

AddFoldPanelWindow and AddFoldPanelSeparator to see how to add items derived from wx.Window to the panels.



AddFoldPanelSeparator(panel, colour=wx.BLACK, spacing=FPB_DEFAULT_SPACING, leftSpacing=FPB_DEFAULT_LEFTLINESPACING, rightSpacing=FPB_DEFAULT_RIGHTLINESPACING)[source]

Adds a separator line to the current fold panel.

The separator is a simple line which is drawn and is no real component. It can be used to separate groups of controls which belong to each other.

Parameters:
  • colour – the separator colour, an instance of wx.Colour;
  • spacing – the separator to be added can be slightly indented from left and right so it is more visibly placed in the fold panel. Use spacing > 0 to give the control an y offset from the previous wx.Window added;

  • leftSpacing – give the added separator a slight indent from the left;
  • rightSpacing – give the added separator a slight indent from the right.


AddFoldPanelWindow(panel, window, flags=FPB_ALIGN_WIDTH, spacing=FPB_DEFAULT_SPACING, leftSpacing=FPB_DEFAULT_LEFTLINESPACING, rightSpacing=FPB_DEFAULT_RIGHTLINESPACING)[source]

Adds a wx.Window derived instance to the referenced fold panel.

Parameters:
  • panel – an instance of FoldPanelItem;
  • window – the window we wish to add to the fold panel, an instance of wx.Window;

  • flags – can be one of the following bits:


    Align Flag Value Description
    FPB_ALIGN_WIDTH 1 The wx.Window to be added will be aligned to fit the width of the FoldPanel when it is resized. Very handy for sizer items, buttons and text boxes.
    FPB_ALIGN_LEFT 0 Aligns left instead of fitting the width of the child window to be added. Use either this one or FPB_ALIGN_WIDTH.
  • spacing – the wx.Window to be added can be slightly indented from left and right so it is more visibly placed in the fold panel. Use spacing > 0 to give the control an y offset from the previous wx.Window added;

  • leftSpacing – give the wx.Window added a slight indent from the left;

  • rightSpacing – give the wx.Window added a slight indent from the right;

Note

Make the window be a child of the fold panel!

The following example adds a FoldPanel to the FoldPanelBar and adds two wx.Window derived controls to the FoldPanel:

# Create the FoldPanelBar
m_pnl = FoldPanelBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, agwStyle=0x2)

# Add a foldpanel to the control. "Test me" is the caption and it is
# initially not collapsed.
item = m_pnl.AddFoldPanel("Test me", False)

# Now add a button to the fold panel. Mind that the button should be
# made child of the FoldPanel and not of the main form.
m_pnl.AddFoldPanelWindow(item, wx.Button(item, ID_COLLAPSEME, "Collapse Me"))

# Add a separator between the two controls. This is purely a visual
# line that can have a certain colour and also the indents and width
# aligning like a control.
m_pnl.AddFoldPanelSeparator(item)

# Now add a text ctrl. Also very easy. Align this on width so that
# when the control gets wider the text control also sizes along.
m_pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, wx.ID_ANY, "Comment"), FPB_ALIGN_WIDTH, FPB_DEFAULT_SPACING, 20)


ApplyCaptionStyle(foldpanel, cbstyle)[source]

Sets the style of the caption bar (CaptionBar) of the fold panel.

Parameters:

Note

The changes are applied immediately. All styles not set in the CaptionBarStyle class are not applied. Use the CaptionBar reference to indicate what captionbar you want to apply the style to. To apply one style to all CaptionBar items, use ApplyCaptionStyleAll.



ApplyCaptionStyleAll(cbstyle)[source]

Sets the style of all the caption bars of the fold panel. The changes are applied immediately.

Parameters:cbstyle – an instance of CaptionBarStyle.


Collapse(foldpanel)[source]

Collapses the given fold panel reference, and updates the foldpanel bar.

Parameters:foldpanel – an instance of FoldPanelItem.

Note

With the FPB_COLLAPSE_TO_BOTTOM style set, all collapsed captions are put at the bottom of the control. In the normal mode, they stay where they are.



Expand(foldpanel)[source]

Expands the given fold panel reference, and updates the foldpanel bar.

Parameters:foldpanel – an instance of FoldPanelItem.

Note

With the FPB_COLLAPSE_TO_BOTTOM style set, they will be removed from the bottom and the order where the panel originally was placed is restored.



GetCaptionStyle(foldpanel)[source]

Returns the currently used caption style for the fold panel.

It is returned as a CaptionBarStyle class. After modifying it, it can be set again.

Parameters:foldpanel – an instance of FoldPanelItem.


GetCount()[source]

Returns the number of panels in the FoldPanelBar.



GetFoldPanel(item)[source]

Returns the panel associated with the index item.

Parameters:item – an integer representing the FoldPanelItem in the list of panels in this FoldPanelBar.


GetPanelsLength(collapsed, expanded)[source]

Returns the length of the panels that are expanded and collapsed.

Parameters:
  • collapsed – the current value of the collapsed panels;
  • expanded – the current value of the expanded panels.

Note

This is useful to determine quickly what size is used to display, and what is left at the bottom (right) to align the collapsed panels.



IsVertical()[source]

Returns whether the CaptionBar has default orientation or not. Default is vertical.



OnPressCaption(event)[source]

Handles the wx.EVT_CAPTIONBAR event for CaptionBar.

Parameters:event – a CaptionBarEvent event to be processed.


OnSizePanel(event)[source]

Handles the wx.EVT_SIZE event for FoldPanelBar.

Parameters:event – a wx.SizeEvent event to be processed.


RedisplayFoldPanelItems()[source]

Resizes the fold panels so they match the width.



RefreshPanelsFrom(item)[source]

Refreshes all the panels from given one down to last one.

Parameters:item – the first FoldPanelItem to be refreshed.


RepositionCollapsedToBottom()[source]

Repositions all the collapsed panels to the bottom.

When it is not possible to align them to the bottom, stick them behind the visible panels.

Tree

Table Of Contents

Previous topic

CaptionBarStyle

Next topic

FoldPanelItem