# wx.lib.agw.ribbon.page.RibbonPage¶

Base class for all the Ribbon stuff.

## Class Hierarchy¶

Inheritance diagram for class RibbonPage:

wxMSW

wxMAC

wxGTK

## Known Superclasses¶

wx.lib.agw.ribbon.control.RibbonControl

## Methods Summary¶

 __init__ Default class constructor. AdjustRectToIncludeScrollButtons Expand a rectangle of the page to include external scroll buttons (if any). CollapsePanels CommonInit DismissExpandedPanel Dismiss the current externally expanded panel, if there is one. DoGetBestSize Gets the size which best suits the window: for a control, it would be the DoSetSize Sets the size of the window in pixels. ExpandPanels GetDefaultBorder Returns the default border style for RibbonPage. GetIcon Get the icon used for the page in the ribbon bar tab area (only displayed if the GetMajorAxis Get the direction in which ribbon panels are stacked within the page. GetMinSize Returns the minimum size of the window, an indication to the sizer layout mechanism HideScrollButtons Layout Layout() -> bool OnEraseBackground Handles the wx.EVT_ERASE_BACKGROUND event for RibbonPage. OnPaint Handles the wx.EVT_PAINT event for RibbonPage. OnSize Handles the wx.EVT_SIZE event for RibbonPage. Realize Perform a full re-layout of all panels on the page. RemoveChild Remove all references to the child from the collapse stack. ScrollLines Scroll the page by some amount up / down / left / right. ScrollPixels Scroll the page by a set number of pixels up / down / left / right. SetArtProvider Set the art provider to be used. SetSizeWithScrollButtonAdjustment Set the size of the page and the external scroll buttons (if any). Show Show(show=True) -> bool ShowScrollButtons

## Class API¶

class RibbonPage(RibbonControl)

Base class for all the Ribbon stuff.

### Methods¶

__init__(self, parent, id=wx.ID_ANY, label="", icon=wx.NullBitmap, style=0)

Default class constructor.

Parameters
• parent – pointer to a parent window, an instance of RibbonBar;

• id – window identifier. If wx.ID_ANY, will automatically create an identifier;

• label – label to be used in the RibbonBar’s tab list for this page (if the ribbon bar is set to display labels);

• icon – the icon used for the page in the ribbon bar tab area (if the ribbon bar is set to display icons);

• style – window style. Currently unused, should be zero.

AdjustRectToIncludeScrollButtons(self, rect)

Expand a rectangle of the page to include external scroll buttons (if any).

When no scroll buttons are shown, has no effect.

Parameters

rect – The rectangle to adjust. The width and height will not be reduced, and the x and y will not be increased.

CollapsePanels(self, direction, minimum_amount)

CommonInit(self, label, icon)

DismissExpandedPanel(self)

Dismiss the current externally expanded panel, if there is one.

When a ribbon panel automatically minimises, it can be externally expanded into a floating window. When the user clicks a button in such a panel, the panel should generally re-minimise. Event handlers for buttons on ribbon panels should call this method to achieve this behaviour.

Returns

True if a panel was minimised, False otherwise.

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.

DoSetSize(self, x, y, width, height, sizeFlags=wx.SIZE_AUTO)

Sets the size of the window in pixels.

Parameters
• x (integer) – required x position in pixels, or wx.DefaultCoord to indicate that the existing value should be used;

• y (integer) – required y position in pixels, or wx.DefaultCoord to indicate that the existing value should be used;

• width (integer) – required width in pixels, or wx.DefaultCoord to indicate that the existing value should be used;

• height (integer) – required height in pixels, or wx.DefaultCoord to indicate that the existing value should be used;

• sizeFlags (integer) –

indicates the interpretation of other parameters. It is a bit list of the following:

• wx.SIZE_AUTO_WIDTH: a wx.DefaultCoord width value is taken to indicate a wxPython-supplied default width.

• wx.SIZE_AUTO_HEIGHT: a wx.DefaultCoord height value is taken to indicate a wxPython-supplied default height.

• wx.SIZE_AUTO: wx.DefaultCoord size values are taken to indicate a wxPython-supplied default size.

• wx.SIZE_USE_EXISTING: existing dimensions should be used if wx.DefaultCoord values are supplied.

• wx.SIZE_ALLOW_MINUS_ONE: allow negative dimensions (i.e. value of wx.DefaultCoord) to be interpreted as real dimensions, not default values.

• wx.SIZE_FORCE: normally, if the position and the size of the window are already the same as the parameters of this function, nothing is done. but with this flag a window resize may be forced even in this case (supported in wx 2.6.2 and later and only implemented for MSW and ignored elsewhere currently).

ExpandPanels(self, direction, maximum_amount)

GetDefaultBorder(self)

Returns the default border style for RibbonPage.

GetIcon(self)

Get the icon used for the page in the ribbon bar tab area (only displayed if the ribbon bar is actually showing icons).

GetMajorAxis(self)

Get the direction in which ribbon panels are stacked within the page.

This is controlled by the style of the containing RibbonBar, meaning that all pages within a bar will have the same major axis. As well as being the direction in which panels are stacked, it is also the axis in which scrolling will occur (when required).

Returns

wx.HORIZONTAL or wx.VERTICAL (never wx.BOTH).

GetMinSize(self)

Returns the minimum size of the window, an indication to the sizer layout mechanism that this is the minimum required size.

This method normally just returns the value set by SetMinSize, but it can be overridden to do the calculation on demand.

HideScrollButtons(self)

Layout(self)

Layout() -> bool

Lays out the children of this window using the associated sizer.

OnEraseBackground(self, event)

Handles the wx.EVT_ERASE_BACKGROUND event for RibbonPage.

Parameters

event – a EraseEvent event to be processed.

OnPaint(self, event)

Handles the wx.EVT_PAINT event for RibbonPage.

Parameters

event – a PaintEvent event to be processed.

OnSize(self, event)

Handles the wx.EVT_SIZE event for RibbonPage.

Parameters

event – a wx.SizeEvent event to be processed.

Realize(self)

Perform a full re-layout of all panels on the page.

Should be called after panels are added to the page, or the sizing behaviour of a panel on the page changes (i.e. due to children being added to it). Usually called automatically when RibbonBar.Realize() is called. Will invoke RibbonPanel.Realize() for all child panels.

Note

Reimplemented from RibbonControl.

RemoveChild(self, child)

Remove all references to the child from the collapse stack.

ScrollLines(self, lines)

Scroll the page by some amount up / down / left / right.

When the page’s children are too big to fit in the onscreen area given to the page, scroll buttons will appear, and the page can be programatically scrolled. Positive values of will scroll right or down, while negative values will scroll up or left (depending on the direction in which panels are stacked). A line is equivalent to a constant number of pixels.

Parameters

lines (integer) – number of lines to scroll the page.

Returns

True if the page scrolled at least one pixel in the given direction, False if it did not scroll.

Note

Reimplemented from wx.Window.

ScrollPixels(self, pixels)

Scroll the page by a set number of pixels up / down / left / right.

When the page’s children are too big to fit in the onscreen area given to the page, scroll buttons will appear, and the page can be programatically scrolled. Positive values of will scroll right or down, while negative values will scroll up or left (depending on the direction in which panels are stacked).

Parameters

pixels (integer) – number of pixels to scroll the page.

Returns

True if the page scrolled at least one pixel in the given direction, False if it did not scroll.

SetArtProvider(self, art)

Set the art provider to be used.

Normally called automatically by RibbonBar when the page is created, or the art provider changed on the bar. The new art provider will be propagated to the children of the page.

Parameters

art – an art provider.

Note

Reimplemented from RibbonControl.

SetSizeWithScrollButtonAdjustment(self, x, y, width, height)

Set the size of the page and the external scroll buttons (if any).

When a page is too small to display all of its children, scroll buttons will appear (and if the page is sized up enough, they will disappear again). Slightly counter-intuively, these buttons are created as siblings of the page rather than children of the page (to achieve correct cropping and paint ordering of the children and the buttons).

When there are no scroll buttons, this function behaves the same as SetSize, however when there are scroll buttons, it positions them at the edges of the given area, and then calls SetSize with the remaining area. This is provided as a separate function to SetSize rather than within the implementation of SetSize, as iteracting algorithms may not expect SetSize to also set the size of siblings.

Parameters
• x – the page x position, in pixels;

• y – the page y position, in pixels;

• width – the page width, in pixels;

• height – the page height, in pixels.

Show(self, show=True)

Show(show=True) -> bool

Shows or hides the window.

ShowScrollButtons(self)