wx.lib.agw.ribbon.bar.RibbonBar¶
Top-level control in a ribbon user interface.
Class Hierarchy¶
Control Appearance¶
Known Superclasses¶
wx.lib.agw.ribbon.control.RibbonControl
Methods Summary¶
Default constructor. |
|
Adds a page to the |
|
Common initialization procedures. |
|
Dismiss the expanded panel of the currently active page. |
|
Does the initial painting of stuff from the |
|
Gets the size which best suits the window: for a control, it would be the |
|
Common methods for all the mouse move/click events. |
|
Get the index of the active page. |
|
Returns the |
|
Returns the default border style for |
|
Get a page by index. |
|
This method should be overridden to return true if this window has multiple pages. |
|
Hit test method for |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Perform initial layout and size calculations of the bar and its children. |
|
Recalculates the |
|
Recalculates the |
|
Repaints the tab area in |
|
Scrolls the tab area left/right/up/down by the specified amount. |
|
See comments on |
|
Set the active page by index, without triggering any events. |
|
Set the active page, without triggering any events. |
|
Sets the window style for |
|
Set the art provider to be used be the ribbon bar. |
|
Set the margin widths (in pixels) on the left and right sides of the tab bar |
|
Shows or hides the panels inside |
Class API¶
- class RibbonBar(RibbonControl)¶
Top-level control in a ribbon user interface.
Methods¶
- __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=RIBBON_BAR_DEFAULT_STYLE, validator=wx.DefaultValidator, name='RibbonBar')¶
Default constructor.
- Parameters:
parent (
wx.Window) – pointer to a parent window, must not beNone;id (integer) – window identifier. If
wx.ID_ANY, will automatically create an identifier;pos (tuple or
wx.Point) – window position.wx.DefaultPositionindicates that wxPython should generate a default position for the window;size (tuple or
wx.Size) – window size.wx.DefaultSizeindicates that wxPython should generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized;agwStyle –
the AGW-specific window style. This can be a combination of the following bits:
Window Styles
Hex Value
Description
RIBBON_BAR_DEFAULT_STYLE0x9
Defined as
RIBBON_BAR_FLOW_HORIZONTAL|RIBBON_BAR_SHOW_PAGE_LABELS|RIBBON_BAR_SHOW_PANEL_EXT_BUTTONSRIBBON_BAR_FOLDBAR_STYLE0x1e
Defined as
RIBBON_BAR_FLOW_VERTICAL|RIBBON_BAR_SHOW_PAGE_ICONS|RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS|RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONSRIBBON_BAR_SHOW_PAGE_LABELS0x1
Causes labels to be shown on the tabs in the ribbon bar.
RIBBON_BAR_SHOW_PAGE_ICONS0x2
Causes icons to be shown on the tabs in the ribbon bar.
RIBBON_BAR_FLOW_HORIZONTAL0x0
Causes panels within pages to stack horizontally.
RIBBON_BAR_FLOW_VERTICAL0x4
Causes panels within pages to stack vertically.
RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS0x8
Causes extension buttons to be shown on panels (where the panel has such a button).
RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS0x10
Causes minimise buttons to be shown on panels (where the panel has such a button).
RIBBON_BAR_ALWAYS_SHOW_TABS0x20
Always shows the tabs area even when only one tab is added.
validator (
wx.Validator) – the window validator;name (string) – the window name.
- AddPage(self, page)¶
Adds a page to the
RibbonBar.- Parameters:
page – an instance of
RibbonPage.
- CommonInit(self, agwStyle)¶
Common initialization procedures.
- Parameters:
agwStyle (integer) – the AGW-specific window style.
See also
SetAGWWindowStyleFlagfor a list of valid window styles.
- DismissExpandedPanel(self)¶
Dismiss the expanded panel of the currently active page.
Calls and returns the value from
RibbonPage.DismissExpandedPanel()for the currently active page, orFalseif there is no active page.
- DoEraseBackground(self, dc)¶
Does the initial painting of stuff from the
OnPaintevent.- Parameters:
dc – an instance of
wx.DC.
- DoGetBestSize(self)¶
Gets the size which best suits the window: for a control, it would be the minimal size which doesn’t truncate the control, for a panel - the same size as it would have after a call to Fit().
- Returns:
An instance of
wx.Size.
Note
Overridden from
wx.Control.
- DoMouseButtonCommon(self, event, tab_event_type)¶
Common methods for all the mouse move/click events.
- Parameters:
event – a
MouseEventevent to be processed;tab_event_type (integer) – one of the
RibbonBarevents.
- GetActivePage(self)¶
Get the index of the active page.
In the rare case of no page being active, -1 is returned.
- GetAGWWindowStyleFlag(self)¶
Returns the
RibbonBarwindow style flag.See also
SetAGWWindowStyleFlagfor a list of valid window styles.
- GetPage(self, n)¶
Get a page by index.
Nonewill be returned if the given index is out of range.- Parameters:
n (integer) – the zero-based index indicating the page position.
- HasMultiplePages(self)¶
This method should be overridden to return true if this window has multiple pages.
All standard class with multiple pages such as
Notebook,ListbookandTreebookalready override it to return true and user-defined classes with similar behaviour should also do so, to allow the library to handle such windows appropriately.
- HitTestTabs(self, position)¶
Hit test method for
RibbonBar, testing where the given (in client coordinates) point lies.- Parameters:
position – an instance of
wx.Pointin client coordinates.- Returns:
a tuple containing the tab index and the
RibbonPageif theHitTestTabssuccessfully found such combination, or a tuple (-1, None) if no tab has been hit.
- OnEraseBackground(self, event)¶
Handles the
wx.EVT_ERASE_BACKGROUNDevent forRibbonBar.- Parameters:
event – a
EraseEventevent to be processed.
- OnMouseDoubleClick(self, event)¶
Handles the
wx.EVT_LEFT_DCLICKevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnMouseLeave(self, event)¶
Handles the
wx.EVT_LEAVE_WINDOWevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnMouseLeftDown(self, event)¶
Handles the
wx.EVT_LEFT_DOWNevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnMouseLeftUp(self, event)¶
Handles the
wx.EVT_LEFT_UPevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnMouseMiddleDown(self, event)¶
Handles the
wx.EVT_MIDDLE_DOWNevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnMouseMiddleUp(self, event)¶
Handles the
wx.EVT_MIDDLE_UPevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnMouseMove(self, event)¶
Handles the
wx.EVT_MOTIONevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnMouseRightDown(self, event)¶
Handles the
wx.EVT_RIGHT_DOWNevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnMouseRightUp(self, event)¶
Handles the
wx.EVT_RIGHT_UPevent forRibbonBar.- Parameters:
event – a
MouseEventevent to be processed.
- OnPaint(self, event)¶
Handles the
wx.EVT_PAINTevent forRibbonBar.- Parameters:
event – a
PaintEventevent to be processed.
- OnSize(self, event)¶
Handles the
wx.EVT_SIZEevent forRibbonBar.- Parameters:
event – a
wx.SizeEventevent to be processed.
- OrderPageTabInfoBySmallWidthAsc(self, first, second)¶
- 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
RibbonPage.Realize()on each child page.Note
Reimplemented from
RibbonControl.
- RepositionPage(self, page)¶
- ScrollTabBar(self, amount)¶
Scrolls the tab area left/right/up/down by the specified amount.
- Parameters:
amount (integer) – the amount by which the tab area is scrolled, in pixels.
- SetActivePage(self, page)¶
See comments on
SetActivePageByIndexandSetActivePageByPage.
- SetActivePageByIndex(self, page)¶
Set the active page by index, without triggering any events.
- Parameters:
page (integer) – The zero-based index of the page to activate.
- Returns:
Trueif the specified page is now active,Falseif it could not be activated (for example because the page index is invalid).
- SetActivePageByPage(self, page)¶
Set the active page, without triggering any events.
- Parameters:
page – the page to activate, an instance of
RibbonPage.- Returns:
Trueif the specified page is now active,Falseif it could not be activated (for example because the given page is not a child of the ribbon bar).
- SetAGWWindowStyleFlag(self, agwStyle)¶
Sets the window style for
RibbonBar.- Parameters:
agwStyle (integer) – can be a combination of the following bits:
Window Styles
Hex Value
Description
RIBBON_BAR_DEFAULT_STYLE0x9
Defined as
RIBBON_BAR_FLOW_HORIZONTAL|RIBBON_BAR_SHOW_PAGE_LABELS|RIBBON_BAR_SHOW_PANEL_EXT_BUTTONSRIBBON_BAR_FOLDBAR_STYLE0x1e
Defined as
RIBBON_BAR_FLOW_VERTICAL|RIBBON_BAR_SHOW_PAGE_ICONS|RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS|RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONSRIBBON_BAR_SHOW_PAGE_LABELS0x1
Causes labels to be shown on the tabs in the ribbon bar.
RIBBON_BAR_SHOW_PAGE_ICONS0x2
Causes icons to be shown on the tabs in the ribbon bar.
RIBBON_BAR_FLOW_HORIZONTAL0x0
Causes panels within pages to stack horizontally.
RIBBON_BAR_FLOW_VERTICAL0x4
Causes panels within pages to stack vertically.
RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS0x8
Causes extension buttons to be shown on panels (where the panel has such a button).
RIBBON_BAR_SHOW_PANEL_MINIMISE_BUTTONS0x10
Causes minimise buttons to be shown on panels (where the panel has such a button).
RIBBON_BAR_ALWAYS_SHOW_TABS0x20
Always shows the tabs area even when only one tab is added.
Note
Please note that some styles cannot be changed after the window creation and that Refresh() might need to be be called after changing the others for the change to take place immediately.
- SetArtProvider(self, art)¶
Set the art provider to be used be the ribbon bar.
Also sets the art provider on all current
RibbonPagechildren, and anyRibbonPagechildren 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
SetArtProvideris 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.
- Parameters:
art – an art provider.
Note
Reimplemented from
RibbonControl.
- 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.
- Parameters:
left (integer) – the left margin (in pixels);
right (integer) – the right margin (in pixels).