.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.ribbon.RibbonBar:

==========================================================================================================================================
|phoenix_title|  **wx.ribbon.RibbonBar**
==========================================================================================================================================

Top-level control in a ribbon user interface.          

Serves as a tabbed container for :ref:`wx.ribbon.RibbonPage`  - a ribbon user interface typically has a ribbon bar, which contains one or more RibbonPages, which in turn each contain one or more RibbonPanels, which in turn contain controls. 

While a :ref:`wx.ribbon.RibbonBar`  has tabs similar to a :ref:`wx.Notebook`, it does not follow the same API for adding pages. Containers like :ref:`wx.Notebook`  can contain any type of window as a page, hence the normal procedure is to create the sub-window and then call :meth:`wx.BookCtrlBase.AddPage` . As :ref:`wx.ribbon.RibbonBar`  can only have :ref:`wx.ribbon.RibbonPage`  as children (and a :ref:`wx.ribbon.RibbonPage`  can only have a :ref:`wx.ribbon.RibbonBar`  as parent), when a page is created, it is automatically added to the bar - there is no AddPage equivalent to call. 

After all pages have been created, and all controls and panels placed on those pages, :meth:`~wx.ribbon.RibbonBar.Realize`  must be called. 





.. _RibbonBar-styles:

|styles| Window Styles
================================

This class supports the following styles: 

  

- ``wx.ribbon.RIBBON_BAR_DEFAULT_STYLE``: Defined as ``wx.ribbon.RIBBON_BAR_FLOW_HORIZONTAL`` | ``wx.ribbon.RIBBON_BAR_SHOW_PAGE_LABELS`` | ``wx.ribbon.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` | ``wx.ribbon.RIBBON_BAR_SHOW_TOGGLE_BUTTON`` | ``wx.ribbon.RIBBON_BAR_SHOW_HELP_BUTTON``.  
- ``wx.ribbon.RIBBON_BAR_FOLDBAR_STYLE``: Defined as ``wx.ribbon.RIBBON_BAR_FLOW_VERTICAL`` | ``wx.ribbon.RIBBON_BAR_SHOW_PAGE_ICONS`` | ``wx.ribbon.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS`` | ``wx.ribbon.RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS``  
- ``wx.ribbon.RIBBON_BAR_SHOW_PAGE_LABELS``: Causes labels to be shown on the tabs in the ribbon bar.  
- ``wx.ribbon.RIBBON_BAR_SHOW_PAGE_ICONS``: Causes icons to be shown on the tabs in the ribbon bar.  
- ``wx.ribbon.RIBBON_BAR_FLOW_HORIZONTAL``: Causes panels within pages to stack horizontally.  
- ``wx.ribbon.RIBBON_BAR_FLOW_VERTICAL``: Causes panels within pages to stack vertically.  
- ``wx.ribbon.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS``: Causes extension buttons to be shown on panels (where the panel has such a button).  
- ``wx.ribbon.RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS``: Causes minimise buttons to be shown on panels (where the panel has such a button).  
- ``wx.ribbon.RIBBON_BAR_SHOW_TOGGLE_BUTTON``: Causes a toggle button to appear on the ribbon bar at top-right corner. This style is new since wxWidgets 2.9.5.  
- ``wx.ribbon.RIBBON_BAR_SHOW_HELP_BUTTON``: Causes a help button to appear on the ribbon bar at the top-right corner. This style is new since wxWidgets 2.9.5.  








.. _RibbonBar-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive a :ref:`wx.ribbon.RibbonBarEvent` parameter.


- EVT_RIBBONBAR_PAGE_CHANGED: Triggered after the transition from one page being active to a different page being active.  
- EVT_RIBBONBAR_PAGE_CHANGING: Triggered prior to the transition from one page being active to a different page being active, and can veto the change.  
- EVT_RIBBONBAR_TAB_MIDDLE_DOWN: Triggered when the middle mouse button is pressed on a tab.  
- EVT_RIBBONBAR_TAB_MIDDLE_UP: Triggered when the middle mouse button is released on a tab.  
- EVT_RIBBONBAR_TAB_RIGHT_DOWN: Triggered when the right mouse button is pressed on a tab.  
- EVT_RIBBONBAR_TAB_RIGHT_UP: Triggered when the right mouse button is released on a tab.  
- EVT_RIBBONBAR_TAB_LEFT_DCLICK: Triggered when the left mouse button is double clicked on a tab.  
- EVT_RIBBONBAR_TOGGLED: Triggered when the button triggering the ribbon bar is clicked. This event is new since wxWidgets 2.9.5.  
- EVT_RIBBONBAR_HELP_CLICK: Triggered when the help button is clicked. This even is new since wxWidgets 2.9.5.  










.. seealso:: :ref:`wx.ribbon.RibbonPage`    







.. seealso:: :ref:`wx.ribbon.RibbonPanel`  







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>RibbonBar</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.ribbon.RibbonBar_inheritance.png" alt="Inheritance diagram of RibbonBar" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Control.html" title="wx.Control" alt="" coords="60,237,148,267"/> <area shape="rect" id="node6" href="wx.ribbon.RibbonControl.html" title="wx.ribbon.RibbonControl" alt="" coords="17,315,191,344"/> <area shape="rect" id="node2" href="wx.Window.html" title="wx.Window" alt="" coords="59,160,148,189"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,87,35"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="48,83,159,112"/> <area shape="rect" id="node5" href="wx.ribbon.RibbonBar.html" title="wx.ribbon.RibbonBar" alt="" coords="29,392,179,421"/> <area shape="rect" id="node7" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="112,5,213,35"/> </map> 
   </p>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.ribbon.RibbonBar.__init__`                                            Default constructor.
:meth:`~wx.ribbon.RibbonBar.AddPageHighlight`                                    Highlight the specified tab.
:meth:`~wx.ribbon.RibbonBar.ArePanelsShown`                                      Indicates whether the panel area of the ribbon bar is shown.
:meth:`~wx.ribbon.RibbonBar.ClearPages`                                          Delete all pages from the ribbon bar.
:meth:`~wx.ribbon.RibbonBar.Create`                                              Create a ribbon bar in two-step ribbon bar construction.
:meth:`~wx.ribbon.RibbonBar.DeletePage`                                          Delete a single page from this ribbon bar.
:meth:`~wx.ribbon.RibbonBar.DismissExpandedPanel`                                Dismiss the expanded panel of the currently active page.
:meth:`~wx.ribbon.RibbonBar.GetActivePage`                                       Get the index of the active page.
:meth:`~wx.ribbon.RibbonBar.GetClassDefaultAttributes`                           
:meth:`~wx.ribbon.RibbonBar.GetPage`                                             Get a page by index.
:meth:`~wx.ribbon.RibbonBar.GetPageCount`                                        Get the number of pages in this bar.
:meth:`~wx.ribbon.RibbonBar.GetPageNumber`                                       Returns the number for a given ribbon bar page.
:meth:`~wx.ribbon.RibbonBar.HidePage`                                            Hides the tab for a given page.
:meth:`~wx.ribbon.RibbonBar.HidePanels`                                          Hides the panel area of the ribbon bar.
:meth:`~wx.ribbon.RibbonBar.IsPageHighlighted`                                   Indicates whether a tab is currently highlighted.
:meth:`~wx.ribbon.RibbonBar.IsPageShown`                                         Indicates whether the tab for the given page is shown to the user or not.
:meth:`~wx.ribbon.RibbonBar.Realize`                                             Perform initial layout and size calculations of the bar and its children.
:meth:`~wx.ribbon.RibbonBar.RemovePageHighlight`                                 Changes a tab to not be highlighted.
:meth:`~wx.ribbon.RibbonBar.SetActivePage`                                       Set the active page by index, without triggering any events.
:meth:`~wx.ribbon.RibbonBar.SetArtProvider`                                      Set the art provider to be used be the ribbon bar.
:meth:`~wx.ribbon.RibbonBar.SetTabCtrlMargins`                                   Set the margin widths (in pixels) on the left and right sides of the tab bar region of the ribbon bar.
:meth:`~wx.ribbon.RibbonBar.ShowPage`                                            Show or hide the tab for a given page.
:meth:`~wx.ribbon.RibbonBar.ShowPanels`                                          Shows or hides the panel area of the ribbon bar.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.ribbon.RibbonBar.ActivePage`                                          See :meth:`~wx.ribbon.RibbonBar.GetActivePage` and :meth:`~wx.ribbon.RibbonBar.SetActivePage`
:attr:`~wx.ribbon.RibbonBar.PageCount`                                           See :meth:`~wx.ribbon.RibbonBar.GetPageCount`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.ribbon.RibbonBar(RibbonControl)

   **Possible constructors**::

       RibbonBar()
       
       RibbonBar(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize,
                 style=RIBBON_BAR_DEFAULT_STYLE)
       
   
   Top-level control in a ribbon user interface.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self)`
      
      Default constructor.                  
      
      With this constructor, :meth:`Create`   should be called in order to create the ribbon bar.                   
      
      
      
      
      **~~~**

      
      **__init__** `(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=RIBBON_BAR_DEFAULT_STYLE)`
      
      Construct a ribbon bar with the given parameters.                  
      
      
      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `style`: 
      :type `style`: long
      
      
      
      
      
      
      **~~~**






   .. method:: AddPageHighlight(self, page, highlight=True)

      Highlight the specified tab.                  

      Highlighted tabs have a colour between that of the active tab and a tab over which the mouse is hovering. This can be used to make a tab (usually temporarily) more noticeable to the user. 

                


      :param `page`: 
      :type `page`: int
      :param `highlight`: 
      :type `highlight`: bool






      .. versionadded:: 2.9.5 
     








   .. method:: ArePanelsShown(self)

      Indicates whether the panel area of the ribbon bar is shown.                  

                

      :rtype: `bool`







      .. versionadded:: 2.9.2 
     







      .. seealso:: :meth:`ShowPanels`   








   .. method:: ClearPages(self)

      Delete all pages from the ribbon bar.                  

                 



      .. versionadded:: 2.9.4 
     








   .. method:: Create(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=RIBBON_BAR_DEFAULT_STYLE)

      Create a ribbon bar in two-step ribbon bar construction.                  

      Should only be called when the default constructor is used, and arguments have the same meaning as in the full constructor.                  


      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `style`: 
      :type `style`: long




      :rtype: `bool`








   .. method:: DeletePage(self, n)

      Delete a single page from this ribbon bar.                  

      The user must call :meth:`wx.ribbon.RibbonBar.Realize`   after one (or more) calls to this function. 

                


      :param `n`: 
      :type `n`: int






      .. versionadded:: 2.9.4 
     








   .. method:: DismissExpandedPanel(self)

      Dismiss the expanded panel of the currently active page.                  

      Calls and returns the value from :meth:`wx.ribbon.RibbonPage.DismissExpandedPanel`   for the currently active page, or ``False`` if there is no active page.                  

      :rtype: `bool`








   .. method:: GetActivePage(self)

      Get the index of the active page.                  

      In the rare case of no page being active, -1 is returned.                  

      :rtype: `int`








   .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)




      :param `variant`: 
      :type `variant`: wx.WindowVariant




      :rtype: :ref:`VisualAttributes`








   .. method:: GetPage(self, n)

      Get a page by index.                  

      ``None`` will be returned if the given index is out of range.                  


      :param `n`: 
      :type `n`: int




      :rtype: :ref:`wx.ribbon.RibbonPage`








   .. method:: GetPageCount(self)

      Get the number of pages in this bar.                  

                

      :rtype: `int`







      .. versionadded:: 2.9.4 
     








   .. method:: GetPageNumber(self, page)

      Returns the number for a given ribbon bar page.                  

      The number can be used in other ribbon bar calls. 

                


      :param `page`: 
      :type `page`: wx.ribbon.RibbonPage




      :rtype: `int`







      .. versionadded:: 2.9.5 
     








   .. method:: HidePage(self, page)

      Hides the tab for a given page.                  

      Equivalent to  ``ShowPage(page, false)`` . 

                


      :param `page`: 
      :type `page`: int






      .. versionadded:: 2.9.5 
     








   .. method:: HidePanels(self)

      Hides the panel area of the ribbon bar.                  

      This method simply calls :meth:`ShowPanels`   with ``False`` argument. 

                 



      .. versionadded:: 2.9.2 
     








   .. method:: IsPageHighlighted(self, page)

      Indicates whether a tab is currently highlighted.                  

                


      :param `page`: 
      :type `page`: int




      :rtype: `bool`







      .. versionadded:: 2.9.5 
     







      .. seealso:: :meth:`AddPageHighlight`   








   .. method:: IsPageShown(self, page)

      Indicates whether the tab for the given page is shown to the user or not.                  

      By default all page tabs are shown. 

                


      :param `page`: 
      :type `page`: int




      :rtype: `bool`







      .. versionadded:: 2.9.5 
     








   .. method:: Realize(self)

      Perform initial layout and size calculations of the bar and its children.                  

      This must be called after all of the bar's children have been created (and their children created, etc.) - if it is not, then windows may not be laid out or sized correctly. 

      Also calls :meth:`wx.ribbon.RibbonPage.Realize`   on each child page.                  

      :rtype: `bool`








   .. method:: RemovePageHighlight(self, page)

      Changes a tab to not be highlighted.                  

                


      :param `page`: 
      :type `page`: int






      .. versionadded:: 2.9.5 
     







      .. seealso:: :meth:`AddPageHighlight`   








   .. method:: SetActivePage(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **SetActivePage** `(self, page)`
      
      Set the active page by index, without triggering any events.                  
      
      
      
      
      :param `page`: The zero-based index of the page to activate.   
      :type `page`: int
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      :returns: 
      
         ``True`` if the specified page is now active, ``False`` if it could not be activated (for example because the page index is invalid).   
      
      
      
      
      
      
      
      **~~~**

      
      **SetActivePage** `(self, page)`
      
      Set the active page, without triggering any events.                  
      
      
      
      
      :param `page`: The page to activate.   
      :type `page`: wx.ribbon.RibbonPage
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      :returns: 
      
         ``True`` if the specified page is now active, ``False`` if it could not be activated (for example because the given page is not a child of the ribbon bar).   
      
      
      
      
      
      
      
      **~~~**






   .. method:: SetArtProvider(self, art)

      Set the art provider to be used be the ribbon bar.                  

      Also sets the art provider on all current :ref:`wx.ribbon.RibbonPage`  children, and any :ref:`wx.ribbon.RibbonPage`  children added in the future. 

      Note that unlike most other ribbon controls, the ribbon bar creates a default art provider when initialised, so an explicit call to :meth:`SetArtProvider`   is not required if the default art provider is sufficient. Also, unlike other ribbon controls, the ribbon bar takes ownership of the given pointer, and will delete it when the art provider is changed or the bar is destroyed. If this behaviour is not desired, then clone the art provider before setting it.                  


      :param `art`: 
      :type `art`: wx.ribbon.RibbonArtProvider







   .. method:: SetTabCtrlMargins(self, left, right)

      Set the margin widths (in pixels) on the left and right sides of the tab bar region of the ribbon bar.                  

      These margins will be painted with the tab background, but tabs and scroll buttons will never be painted in the margins. 

      The left margin could be used for rendering something equivalent to the "Office Button", though this is not currently implemented. The right margin could be used for rendering a help button, and/or MDI buttons, but again, this is not currently implemented.                  


      :param `left`: 
      :type `left`: int
      :param `right`: 
      :type `right`: int







   .. method:: ShowPage(self, page, show_tab=True)

      Show or hide the tab for a given page.                  

      After showing or hiding a tab, you need to call :meth:`wx.ribbon.RibbonBar.Realize` . If you hide the tab for the currently active page (GetActivePage) then you should call SetActivePage to activate a different page. 

                


      :param `page`: 
      :type `page`: int
      :param `show_tab`: 
      :type `show_tab`: bool






      .. versionadded:: 2.9.5 
     








   .. method:: ShowPanels(self, show=True)

      Shows or hides the panel area of the ribbon bar.                  

      If the panel area is hidden, then only the tab of the ribbon bar will be shown. This is useful for giving the user more screen space to work with when he/she doesn't need to see the ribbon's options. 

                


      :param `show`: 
      :type `show`: bool






      .. versionadded:: 2.9.2 
     








   .. attribute:: ActivePage

      See :meth:`~wx.ribbon.RibbonBar.GetActivePage` and :meth:`~wx.ribbon.RibbonBar.SetActivePage`


   .. attribute:: PageCount

      See :meth:`~wx.ribbon.RibbonBar.GetPageCount`

