wx.lib.agw.ribbon.buttonbar.RibbonButtonBar¶
A ribbon button bar is similar to a traditional toolbar.
Class Hierarchy¶
Control Appearance¶
Known Superclasses¶
wx.lib.agw.ribbon.control.RibbonControl
Methods Summary¶
Default class constructor. |
|
Add a button to the button bar. |
|
Add a dropdown button to the button bar (simple version). |
|
Add a hybrid button to the button bar (simple version). |
|
Add a button to the button bar (simple version). |
|
Add a toggle button to the button bar. |
|
Delete all buttons from the button bar. |
|
Common initialization procedures. |
|
Delete a single button from the button bar. |
|
Gets the size which best suits the window: for a control, it would be the |
|
Implementation of |
|
Implementation of |
|
Enable or disable a single button on the bar. |
|
Returns the number of buttons in this |
|
Returns the default border style for |
|
Returns the minimum size of the window, an indication to the sizer layout mechanism |
|
Inserts a button in the button bar at the position specified by pos. |
|
Inserts a dropdown button in the button bar at the position specified by pos. |
|
Inserts a hybrid button in the button bar at the position specified by pos. |
|
Inserts a toggle button in the button bar at the position specified by pos. |
|
Returns whether a button in the bar is enabled or not. |
|
Returns |
|
Converts the original bitmap into a visually-looking disabled one. |
|
Resize and scale the original bitmap to the dimensions specified in size. |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Calculate button layouts and positions. |
|
Set the art provider to be used. |
|
Toggles/untoggles a |
|
This function sends one or more |
Class API¶
- class RibbonButtonBar(RibbonControl)¶
A ribbon button bar is similar to a traditional toolbar.
Methods¶
- __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, agwStyle=0)¶
Default class constructor.
- Parameters:
parent (
wx.Window
) – pointer to a parent window, typically aRibbonPanel
;id (integer) – window identifier. If
wx.ID_ANY
, will automatically create an identifier;pos (tuple or
wx.Point
) – window position.wx.DefaultPosition
indicates that wxPython should generate a default position for the window;size (tuple or
wx.Size
) – window size.wx.DefaultSize
indicates 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 (integer) – the AGW-specific window style, currently unused.
- AddButton(self, button_id, label, bitmap, bitmap_small=wx.NullBitmap, bitmap_disabled=wx.NullBitmap, bitmap_small_disabled=wx.NullBitmap, kind=RIBBON_BUTTON_NORMAL, help_string='', client_data=None)¶
Add a button to the button bar.
- Parameters:
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;bitmap_small – small bitmap of the new button, an instance of
wx.Bitmap
. If left asNullBitmap
, then a small bitmap will be automatically generated. Must be the same size as all other small bitmaps used on the button bar;bitmap_disabled – large bitmap of the new button when it is disabled, an instance of
wx.Bitmap
. If left asNullBitmap
, then a bitmap will be automatically generated from bitmap;bitmap_small_disabled – small bitmap of the new button when it is disabled, an instance of
wx.Bitmap
. If left asNullBitmap
, then a bitmap will be automatically generated from bitmap_small;kind (integer) – the kind of button to add, one of the following values:
Button Kind
Hex Value
Description
RIBBON_BUTTON_NORMAL
0x1
Normal button or tool with a clickable area which causes some generic action.
RIBBON_BUTTON_DROPDOWN
0x2
Dropdown button or tool with a clickable area which typically causes a dropdown menu.
RIBBON_BUTTON_HYBRID
0x3
Button or tool with two clickable areas - one which causes a dropdown menu, and one which causes a generic action.
RIBBON_BUTTON_TOGGLE
0x4
Normal button or tool with a clickable area which toggles the button between a pressed and unpressed state.
help_string (string) – the UI help string to associate with the new button;
client_data (object) – client data to associate with the new button (any Python object).
- Returns:
An opaque pointer which can be used only with other button bar methods.
See also
- AddDropdownButton(self, button_id, label, bitmap, help_string='')¶
Add a dropdown button to the button bar (simple version).
- Parameters:
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;help_string (string) – the UI help string to associate with the new button.
- Returns:
An opaque pointer which can be used only with other button bar methods.
See also
- AddHybridButton(self, button_id, label, bitmap, help_string='')¶
Add a hybrid button to the button bar (simple version).
- Parameters:
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;help_string (string) – the UI help string to associate with the new button.
- Returns:
An opaque pointer which can be used only with other button bar methods.
See also
- AddSimpleButton(self, button_id, label, bitmap, help_string, kind=RIBBON_BUTTON_NORMAL)¶
Add a button to the button bar (simple version).
- Parameters:
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;help_string (string) – the UI help string to associate with the new button;
kind (integer) – the kind of button to add.
- Returns:
An opaque pointer which can be used only with other button bar methods.
See also
AddButton
for a list of valid button kind values.
- AddToggleButton(self, button_id, label, bitmap, help_string='')¶
Add a toggle button to the button bar.
- Parameters:
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;help_string (string) – the UI help string to associate with the new button.
- Returns:
An opaque pointer which can be used only with other button bar methods.
See also
- ClearButtons(self)¶
Delete all buttons from the button bar.
See also
- CommonInit(self, agwStyle)¶
Common initialization procedures.
- Parameters:
agwStyle (integer) – the AGW-specific window style, currently unused.
- DeleteButton(self, button_id)¶
Delete a single button from the button bar.
- Parameters:
button_id (integer) – id of the button to delete.
- Returns:
True
if the button has been found and successfully deleted,False
otherwise.
See also
- 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
.
- DoGetNextLargerSize(self, direction, _result)¶
Implementation of
RibbonControl.GetNextLargerSize()
.Controls which have non-continuous sizing must override this virtual function rather than
RibbonControl.GetNextLargerSize()
.- Returns:
An instance of
wx.Size
.
- DoGetNextSmallerSize(self, direction, _result)¶
Implementation of
RibbonControl.GetNextSmallerSize()
.Controls which have non-continuous sizing must override this virtual function rather than
RibbonControl.GetNextSmallerSize()
.- Returns:
An instance of
wx.Size
.
- EnableButton(self, button_id, enable=True)¶
Enable or disable a single button on the bar.
- Parameters:
button_id (integer) – id of the button to enable or disable;
enable (bool) –
True
to enable the button,False
to disable it.
- Raise:
Exception when the input button_id could not be associated with a
RibbonButtonBar
button.
- FetchButtonSizeInfo(self, button, size, dc)¶
- GetButtonCount(self)¶
Returns the number of buttons in this
RibbonButtonBar
.Added in version 0.9.5.
- GetDefaultBorder(self)¶
Returns the default border style for
RibbonButtonBar
.
- 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.- Returns:
An instance of
wx.Size
.
- InsertButton(self, pos, button_id, label, bitmap, bitmap_small=wx.NullBitmap, bitmap_disabled=wx.NullBitmap, bitmap_small_disabled=wx.NullBitmap, kind=RIBBON_BUTTON_NORMAL, help_string='', client_data=None)¶
Inserts a button in the button bar at the position specified by pos.
- Parameters:
pos (integer) – the position at which the new button must be inserted (zero-based);
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;bitmap_small – small bitmap of the new button, an instance of
wx.Bitmap
. If left asNullBitmap
, then a small bitmap will be automatically generated. Must be the same size as all other small bitmaps used on the button bar;bitmap_disabled – large bitmap of the new button when it is disabled, an instance of
wx.Bitmap
. If left asNullBitmap
, then a bitmap will be automatically generated from bitmap;bitmap_small_disabled – small bitmap of the new button when it is disabled, an instance of
wx.Bitmap
. If left asNullBitmap
, then a bitmap will be automatically generated from bitmap_small;kind (integer) – the kind of button to add;
help_string (string) – the UI help string to associate with the new button;
client_data (object) – client data to associate with the new button.
- Returns:
An opaque pointer which can be used only with other button bar methods.
- Raise:
Exception if both bitmap and bitmap_small are invalid or if the input help_string is not a valid Python basestring.
See also
AddDropdownButton
,AddHybridButton
andAddButton
for a list of valid button kind values.Added in version 0.9.5.
- InsertDropdownButton(self, pos, button_id, label, bitmap, help_string='')¶
Inserts a dropdown button in the button bar at the position specified by pos.
- Parameters:
pos (integer) – the position at which the new button must be inserted (zero-based);
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;help_string (string) – the UI help string to associate with the new button.
- Returns:
An opaque pointer which can be used only with other button bar methods.
See also
Added in version 0.9.5.
- InsertHybridButton(self, pos, button_id, label, bitmap, help_string='')¶
Inserts a hybrid button in the button bar at the position specified by pos.
- Parameters:
pos (integer) – the position at which the new button must be inserted (zero-based);
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;help_string (string) – the UI help string to associate with the new button.
- Returns:
An opaque pointer which can be used only with other button bar methods.
See also
Added in version 0.9.5.
- InsertToggleButton(self, pos, button_id, label, bitmap, help_string='')¶
Inserts a toggle button in the button bar at the position specified by pos.
- Parameters:
pos (integer) – the position at which the new button must be inserted (zero-based);
button_id (integer) – id of the new button (used for event callbacks);
label (string) – label of the new button;
bitmap – large bitmap of the new button, an instance of
wx.Bitmap
. Must be the same size as all other large bitmaps used on the button bar;help_string (string) – the UI help string to associate with the new button.
- Returns:
An opaque pointer which can be used only with other button bar methods.
See also
Added in version 0.9.5.
- IsButtonEnabled(self, button_id)¶
Returns whether a button in the bar is enabled or not.
- Parameters:
button_id (integer) – id of the button to check.
- Returns:
True
if the button is enabled,False
otherwise.- Raise:
Exception when the input button_id could not be associated with a
RibbonButtonBar
button.
- IsSizingContinuous(self)¶
Returns
True
if this window can take any size (greater than its minimum size),False
if it can only take certain sizes.See also
RibbonControl.GetNextSmallerSize()
,RibbonControl.GetNextLargerSize()
- MakeDisabledBitmap(self, original)¶
Converts the original bitmap into a visually-looking disabled one.
- Parameters:
original – the original bitmap, an instance of
wx.Bitmap
.- Returns:
A visually-looking disabled representation of the input bitmap.
- MakeLayouts(self)¶
- MakeResizedBitmap(self, original, size)¶
Resize and scale the original bitmap to the dimensions specified in size.
- OnEraseBackground(self, event)¶
Handles the
wx.EVT_ERASE_BACKGROUND
event forRibbonButtonBar
.- Parameters:
event – a
EraseEvent
event to be processed.
- OnMouseDown(self, event)¶
Handles the
wx.EVT_LEFT_DOWN
event forRibbonButtonBar
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseEnter(self, event)¶
Handles the
wx.EVT_ENTER_WINDOW
event forRibbonButtonBar
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseLeave(self, event)¶
Handles the
wx.EVT_LEAVE_WINDOW
event forRibbonButtonBar
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseMove(self, event)¶
Handles the
wx.EVT_MOTION
event forRibbonButtonBar
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMouseUp(self, event)¶
Handles the
wx.EVT_LEFT_UP
event forRibbonButtonBar
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnPaint(self, event)¶
Handles the
wx.EVT_PAINT
event forRibbonButtonBar
.- Parameters:
event – a
PaintEvent
event to be processed.
- OnSize(self, event)¶
Handles the
wx.EVT_SIZE
event forRibbonButtonBar
.- Parameters:
event – a
wx.SizeEvent
event to be processed.
- Realize(self)¶
Calculate button layouts and positions.
Must be called after buttons are added to the button bar, as otherwise the newly added buttons will not be displayed. In normal situations, it will be called automatically when
RibbonBar.Realize()
is called.Note
Reimplemented from
RibbonControl
.
- SetArtProvider(self, art)¶
Set the art provider to be used.
In many cases, setting the art provider will also set the art provider on all child windows which extend
RibbonControl
. In most cases, controls will not take ownership of the given pointer, with the notable exception beingRibbonBar.SetArtProvider()
.- Parameters:
art – an art provider.
- ToggleButton(self, button_id, checked=True)¶
Toggles/untoggles a
RibbonButtonBar
toggle button.- Parameters:
button_id (integer) – id of the button to be toggles/untoggled;
checked (bool) –
True
to toggle the button,False
to untoggle it.
- Raise:
Exception when the input button_id could not be associated with a
RibbonButtonBar
button.
- TryCollapseLayout(self, original, first_btn, last_button=None)¶
- UpdateWindowUI(self, flags)¶
This function sends one or more
UpdateUIEvent
to the window.The particular implementation depends on the window; for example a
ToolBar
will send an update UI event for each toolbar button, and awx.Frame
will send an update UI event for each menubar menu item.You can call this function from your application to ensure that your UI is up-to-date at this point (as far as your
UpdateUIEvent
handlers are concerned). This may be necessary if you have calledUpdateUIEvent.SetMode
orUpdateUIEvent.SetUpdateInterval
to limit the overhead that wxWidgets incurs by sending update UI events in idle time.- Parameters:
flags (integer) – should be a bitlist of one or more of
wx.UPDATE_UI_NONE
,wx.UPDATE_UI_RECURSE
orwx.UPDATE_UI_FROMIDLE
.
If you are calling this function from an
OnInternalIdle
or OnIdle function, make sure you pass thewx.UPDATE_UI_FROMIDLE
flag, since this tells the window to only update the UI elements that need to be updated in idle time. Some windows update their elements only when necessary, for example when a menu is about to be shown. The following is an example of how to callUpdateWindowUI
from an idle function:def OnInternalIdle(self): if wx.UpdateUIEvent.CanUpdate(self): self.UpdateWindowUI(wx.UPDATE_UI_FROMIDLE)
Added in version 0.9.5.