.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. currentmodule:: wx.lib.agw.foldpanelbar .. highlight:: python .. _wx.lib.agw.foldpanelbar.FoldPanelBar: ========================================================================================================================================== |phoenix_title| **wx.lib.agw.foldpanelbar.FoldPanelBar** ========================================================================================================================================== The :class:`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 :meth:`FoldPanelBar.AddFoldPanel() `. Then use the :meth:`FoldPanelBar.AddFoldPanelWindow() ` to add :class:`wx.Window` derived controls to the current fold panel. Use :meth:`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. | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class FoldPanelBar:
| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/wx.lib.agw.foldpanelbar.foldpanelbar.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/../no_appearance.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/../no_appearance.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |super_classes| Known Superclasses ================================== :class:`wx.Panel` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.__init__` Default class constructor. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.AddFoldPanel` Adds a fold panel to the list of panels. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.AddFoldPanelSeparator` Adds a separator line to the current fold panel. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.AddFoldPanelWindow` Adds a :class:`wx.Window` derived instance to the referenced fold panel. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.ApplyCaptionStyle` Sets the style of the caption bar (:class:`CaptionBar`) of the fold panel. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.ApplyCaptionStyleAll` Sets the style of all the caption bars of the fold panel. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.Collapse` Collapses the given fold panel reference, and updates the foldpanel bar. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.Expand` Expands the given fold panel reference, and updates the foldpanel bar. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.GetCaptionStyle` Returns the currently used caption style for the fold panel. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.GetCount` Returns the number of panels in the :class:`FoldPanelBar`. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.GetFoldPanel` Returns the panel associated with the index `item`. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.GetPanelsLength` Returns the length of the panels that are expanded and :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.IsVertical` Returns whether the :class:`CaptionBar` has default orientation or not. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.OnPressCaption` Handles the ``wx.EVT_CAPTIONBAR`` event for :class:`CaptionBar`. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.OnSizePanel` Handles the ``wx.EVT_SIZE`` event for :class:`FoldPanelBar`. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.RedisplayFoldPanelItems` Resizes the fold panels so they match the width. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.RefreshPanelsFrom` Refreshes all the panels from given one down to last one. :meth:`~wx.lib.agw.foldpanelbar.FoldPanelBar.RepositionCollapsedToBottom` Repositions all the collapsed panels to the bottom. ================================================================================ ================================================================================ | |api| Class API =============== .. class:: FoldPanelBar(wx.Panel) The :class:`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 :meth:`FoldPanelBar.AddFoldPanel() `. Then use the :meth:`FoldPanelBar.AddFoldPanelWindow() ` to add :class:`wx.Window` derived controls to the current fold panel. Use :meth:`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. .. method:: __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL|wx.NO_BORDER, agwStyle=0) Default class constructor. :param `parent`: the :class:`FoldPanelBar` parent window; :param `id`: an identifier for the control: a value of -1 is taken to mean a default; :param `pos`: the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform; :param `size`: the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform; :param `style`: the underlying :class:`Panel` window style; :param `agwStyle`: the AGW-specific :class:`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 :class:`FoldPanelBar` will be horizontal. ``FPB_VERTICAL`` 0x8 :class:`FoldPanelBar` will be vertical. ========================== =========== ================================================== .. method:: AddFoldPanel(self, caption="", collapsed=False, foldIcons=None, cbstyle=None) Adds a fold panel to the list of panels. :param `caption`: the caption to be displayed in the associated :class:`CaptionBar`; :param `collapsed`: if set to ``True``, the panel is collapsed initially; :param `foldIcons`: an instance of :class:`wx.ImageList` containing the icons to display next to the caption text; :param `cbstyle`: an instance of :class:`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. .. seealso:: :meth:`~FoldPanelBar.AddFoldPanelWindow` and :meth:`~FoldPanelBar.AddFoldPanelSeparator` to see how to add items derived from :class:`wx.Window` to the panels. .. method:: AddFoldPanelSeparator(self, panel, colour=wx.BLACK, spacing=FPB_DEFAULT_SPACING, leftSpacing=FPB_DEFAULT_LEFTLINESPACING, rightSpacing=FPB_DEFAULT_RIGHTLINESPACING) 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. :param `colour`: the separator colour, an instance of :class:`wx.Colour`; :param `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 :class:`wx.Window` added; :param `leftSpacing`: give the added separator a slight indent from the left; :param `rightSpacing`: give the added separator a slight indent from the right. .. method:: AddFoldPanelWindow(self, panel, window, flags=FPB_ALIGN_WIDTH, spacing=FPB_DEFAULT_SPACING, leftSpacing=FPB_DEFAULT_LEFTLINESPACING, rightSpacing=FPB_DEFAULT_RIGHTLINESPACING) Adds a :class:`wx.Window` derived instance to the referenced fold panel. :param `panel`: an instance of :class:`FoldPanelItem`; :param `window`: the window we wish to add to the fold panel, an instance of :class:`wx.Window`; :param `flags`: can be one of the following bits: ====================== ======= ==================================== Align Flag Value Description ====================== ======= ==================================== ``FPB_ALIGN_WIDTH`` 1 The :class:`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``. ====================== ======= ==================================== :param `spacing`: the :class:`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 :class:`wx.Window` added; :param `leftSpacing`: give the :class:`wx.Window` added a slight indent from the left; :param `rightSpacing`: give the :class:`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 :class:`FoldPanelBar` and adds two :class:`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) .. method:: ApplyCaptionStyle(self, foldpanel, cbstyle) Sets the style of the caption bar (:class:`CaptionBar`) of the fold panel. :param `foldpanel`: an instance of :class:`FoldPanelItem`; :param `cbstyle`: an instance of :class:`CaptionBarStyle`. .. note:: The changes are applied immediately. All styles not set in the :class:`CaptionBarStyle` class are not applied. Use the :class:`CaptionBar` reference to indicate what captionbar you want to apply the style to. To apply one style to all :class:`CaptionBar` items, use :meth:`~FoldPanelBar.ApplyCaptionStyleAll`. .. method:: ApplyCaptionStyleAll(self, cbstyle) Sets the style of all the caption bars of the fold panel. The changes are applied immediately. :param `cbstyle`: an instance of :class:`CaptionBarStyle`. .. method:: Collapse(self, foldpanel) Collapses the given fold panel reference, and updates the foldpanel bar. :param `foldpanel`: an instance of :class:`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. .. method:: Expand(self, foldpanel) Expands the given fold panel reference, and updates the foldpanel bar. :param `foldpanel`: an instance of :class:`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. .. method:: GetCaptionStyle(self, foldpanel) Returns the currently used caption style for the fold panel. It is returned as a :class:`CaptionBarStyle` class. After modifying it, it can be set again. :param `foldpanel`: an instance of :class:`FoldPanelItem`. .. method:: GetCount(self) Returns the number of panels in the :class:`FoldPanelBar`. .. method:: GetFoldPanel(self, item) Returns the panel associated with the index `item`. :param `item`: an integer representing the :class:`FoldPanelItem` in the list of panels in this :class:`FoldPanelBar`. .. method:: GetPanelsLength(self, collapsed, expanded) Returns the length of the panels that are expanded and collapsed. :param `collapsed`: the current value of the collapsed panels; :param `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. .. method:: IsVertical(self) Returns whether the :class:`CaptionBar` has default orientation or not. Default is vertical. .. method:: OnPressCaption(self, event) Handles the ``wx.EVT_CAPTIONBAR`` event for :class:`CaptionBar`. :param `event`: a :class:`CaptionBarEvent` event to be processed. .. method:: OnSizePanel(self, event) Handles the ``wx.EVT_SIZE`` event for :class:`FoldPanelBar`. :param `event`: a :class:`wx.SizeEvent` event to be processed. .. method:: RedisplayFoldPanelItems(self) Resizes the fold panels so they match the width. .. method:: RefreshPanelsFrom(self, item) Refreshes all the panels from given one down to last one. :param `item`: the first :class:`FoldPanelItem` to be refreshed. .. method:: RepositionCollapsedToBottom(self) 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.