auibar.AuiToolBar

Inheritance diagram for AuiToolBar:


digraph inheritancee38f291ecd {
rankdir=LR;
size="8.0, 12.0";
  "wx._controls.PyControl" [shape=box,style="setlinewidth(0.5)",fontsize=10,fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,height=0.25];
  "wx._core.Control" -> "wx._controls.PyControl" [arrowsize=0.5,style="setlinewidth(0.5)"];
  "wx._core.Window" [shape=box,style="setlinewidth(0.5)",fontsize=10,fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,height=0.25];
  "wx._core.EvtHandler" -> "wx._core.Window" [arrowsize=0.5,style="setlinewidth(0.5)"];
  "auibar.AuiToolBar" [style="setlinewidth(0.5)",URL="#auibar.AuiToolBar",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,height=0.25,shape=box,fontsize=10];
  "wx._controls.PyControl" -> "auibar.AuiToolBar" [arrowsize=0.5,style="setlinewidth(0.5)"];
  "wx._core.EvtHandler" [shape=box,style="setlinewidth(0.5)",fontsize=10,fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,height=0.25];
  "wx._core.Object" -> "wx._core.EvtHandler" [arrowsize=0.5,style="setlinewidth(0.5)"];
  "wx._core.Object" [shape=box,style="setlinewidth(0.5)",fontsize=10,fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,height=0.25];
  "wx._core.Control" [shape=box,style="setlinewidth(0.5)",fontsize=10,fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,height=0.25];
  "wx._core.Window" -> "wx._core.Control" [arrowsize=0.5,style="setlinewidth(0.5)"];
}


Description

AuiToolBar is a completely owner-drawn toolbar perfectly integrated with the AUI layout system. This allows drag and drop of toolbars, docking/floating behaviour and the possibility to define “overflow” items in the toolbar itself.

The default theme that is used is AuiDefaultToolBarArt, which provides a modern, glossy look and feel. The theme can be changed by calling AuiToolBar.SetArtProvider.

Class API

Methods

class AuiToolBar(parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=0)

Bases: wx._controls.PyControl

AuiToolBar is a completely owner-drawn toolbar perfectly integrated with the AUI layout system. This allows drag and drop of toolbars, docking/floating behaviour and the possibility to define “overflow” items in the toolbar itself.

The default theme that is used is AuiDefaultToolBarArt, which provides a modern, glossy look and feel. The theme can be changed by calling AuiToolBar.SetArtProvider.

__init__()

Default class constructor.

Parameters:
  • parent – the L{AuiToolBar} parent;
  • id – an identifier for the control: a value of -1 is taken to mean a default;
  • pos – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;
  • size – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;
  • style – the window style. This can be a combination of the bollowing bits:
Flag name Description
AUI_TB_TEXT Shows the text in the toolbar buttons; by default only icons are shown
AUI_TB_NO_TOOLTIPS Don’t show tooltips on AuiToolBar items
AUI_TB_NO_AUTORESIZE Do not auto-resize the AuiToolBar
AUI_TB_GRIPPER Shows a gripper on the AuiToolBar
AUI_TB_OVERFLOW The AuiToolBar can contain overflow items
AUI_TB_VERTICAL The AuiToolBar is vertical
AUI_TB_HORZ_LAYOUT Shows the text and the icons alongside, not vertically stacked. This style must be used with AUI_TB_TEXT.
AUI_TB_PLAIN_BACKGROUND Don’t draw a gradient background on the toolbar
AUI_TB_HORZ_TEXT Combination of AUI_TB_HORZ_LAYOUT and AUI_TB_TEXT

The default value for style is: AUI_TB_DEFAULT_STYLE = 0

AddCheckTool(tool_id, label, bitmap, disabled_bitmap, short_help_string='', long_help_string='', client_data=None)
Adds a new check (or toggle) tool to the L{AuiToolBar}. The parameters are the same as in L{AddTool}.
AddControl(control, label='')

Adds any control to the toolbar, typically e.g. a combobox.

Parameters:
  • control – the control to be added;
  • label – the label which appears if the control goes into the overflow items in the toolbar.
AddLabel(tool_id, label='', width=0)

Adds a label tool to the L{AuiToolBar}.

Parameters:
  • tool_id – an integer by which the tool may be identified in subsequent operations;
  • label – the toolbar tool label;
  • width – the tool width.
AddRadioTool(tool_id, label, bitmap, disabled_bitmap, short_help_string='', long_help_string='', client_data=None)

Adds a new radio tool to the toolbar. Consecutive radio tools form a radio group such that exactly one button in the group is pressed at any moment, in other words whenever a button in the group is pressed the previously pressed button is automatically released. You should avoid having the radio groups of only one element as it would be impossible for the user to use such button.

By default, the first button in the radio group is initially pressed, the others are not.

The parameters are the same as in L{AddTool}.

AddSeparator()
Adds a separator for spacing groups of tools.
AddSimpleTool(tool_id, label, bitmap, short_help_string='', kind=0)

Adds a tool to the toolbar. This is the simplest method you can use to ass an item to the L{AuiToolBar}.

Parameters:
  • tool_id – an integer by which the tool may be identified in subsequent operations;
  • label – the toolbar tool label;
  • bitmap – the primary tool bitmap;
  • short_help_string – this string is used for the tools tooltip;
  • kind – the item kind. Can be one of the following:
Item Kind Description
ITEM_CONTROL The item in the AuiToolBar is a control
ITEM_LABEL The item in the AuiToolBar is a text label
ITEM_SPACER The item in the AuiToolBar is a spacer
ITEM_SEPARATOR The item in the AuiToolBar is a separator
ITEM_CHECK The item in the AuiToolBar is a toolbar check item
ITEM_NORMAL The item in the AuiToolBar is a standard toolbar item
ITEM_RADIO The item in the AuiToolBar is a toolbar radio item
AddSpacer(pixels)

Adds a spacer for spacing groups of tools.

Parameter:pixels – the width of the spacer.
AddStretchSpacer(proportion=1)

Adds a stretchable spacer for spacing groups of tools.

Parameter:proportion – the stretchable spacer proportion.
AddToggleTool(tool_id, bitmap, disabled_bitmap, toggle=False, client_data=None, short_help_string='', long_help_string='')

Adds a toggle tool to the toolbar.

Parameters:
  • tool_id – an integer by which the tool may be identified in subsequent operations;
  • bitmap – the primary tool bitmap;
  • disabled_bitmap – the bitmap to use when the tool is disabled. If it is equal to wx.NullBitmap, the disabled bitmap is automatically generated by greing the normal one;
  • client_data – whatever Python object to associate with the toolbar item;
  • short_help_string – this string is used for the tools tooltip;
  • long_help_string – this string is shown in the statusbar (if any) of the parent frame when the mouse pointer is inside the tool.
AddTool(tool_id, label, bitmap, disabled_bitmap, kind, short_help_string, long_help_string, client_data)

Adds a tool to the toolbar. This is the full feature version of AddTool.

Parameters:
  • tool_id – an integer by which the tool may be identified in subsequent operations;
  • label – the toolbar tool label;
  • bitmap – the primary tool bitmap;
  • disabled_bitmap – the bitmap to use when the tool is disabled. If it is equal to wx.NullBitmap, the disabled bitmap is automatically generated by greing the normal one;
  • kind – the item kind. Can be one of the following:
Item Kind Description
ITEM_CONTROL The item in the AuiToolBar is a control
ITEM_LABEL The item in the AuiToolBar is a text label
ITEM_SPACER The item in the AuiToolBar is a spacer
ITEM_SEPARATOR The item in the AuiToolBar is a separator
ITEM_CHECK The item in the AuiToolBar is a toolbar check item
ITEM_NORMAL The item in the AuiToolBar is a standard toolbar item
ITEM_RADIO The item in the AuiToolBar is a toolbar radio item
Parameters:
  • short_help_string – this string is used for the tools tooltip;
  • long_help_string – this string is shown in the statusbar (if any) of the parent frame when the mouse pointer is inside the tool.
  • client_data – whatever Python object to associate with the toolbar item.
Clear()
Deletes all the tools in the L{AuiToolBar}.
ClearTools()
Deletes all the tools in the L{AuiToolBar}.
DeleteTool(tool_id)

Removes the specified tool from the toolbar and deletes it. If you don’t want to delete the tool, but just to remove it from the toolbar (to possibly add it back later), you may use L{RemoveTool} instead.

Parameter:tool_id – the L{AuiToolBarItem} identifier.

@note: Note that it is unnecessary to call L{Realize} for the change to take place, it will happen immediately.

Returns True if the tool was deleted, False otherwise.

DeleteToolByPos(pos)

This function behaves like L{DeleteTool} but it deletes the tool at the specified position and not the one with the given id.

Parameter:pos – the tool position.
DoGetBestSize()
Overridden from wx.PyControl.
DoIdleUpdate()
Updates the toolbar during idle times.
DoSetSize(x, y, width, height, sizeFlags=3)

Overridden from wx.PyControl.

Sets the position and size of the window in pixels. The flags parameter indicates the interpretation of the other params if they are equal to -1.

Parameters:
  • x – the window x position;
  • y – the window y position;
  • width – the window width;
  • height – the window height;
  • flags – may have one of this bit set:
Size Flags Description
wx.SIZE_AUTO A -1 indicates that a class-specific default should be used.
wx.SIZE_AUTO_WIDTH A -1 indicates that a class-specific default should be used for the width.
wx.SIZE_AUTO_HEIGHT A -1 indicates that a class-specific default should be used for the height.
wx.SIZE_USE_EXISTING Existing dimensions should be used if -1 values are supplied.
wx.SIZE_ALLOW_MINUS_ONE Allow dimensions of -1 and less 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)
EnableTool(tool_id, state)

Enables or disables the tool.

Parameters:
  • tool_id – tool to enable or disable.
  • state – if True, enables the tool, otherwise disables it.
FindControl(id)

Returns a pointer to the control identified by id or None if no corresponding control is found.

Parameter:id – the control identifier.
FindTool(tool_id)

Finds a tool for the given tool id.

Parameter:tool_id – the L{AuiToolBarItem} identifier.
FindToolByIndex(pos)

Finds a tool for the given tool position in the L{AuiToolBar}.

Parameter:pos – the tool position in the toolbar.
FindToolForPosition(x, y)

Finds a tool for the given mouse position.

Parameters:
  • xx position;
  • yy position.

Returns a pointer to a L{AuiToolBarItem} if a tool is found, or None otherwise.

FindToolForPositionWithPacking(x, y)

Finds a tool for the given mouse position, taking into account also the tool packing.

Parameters:
  • xx position;
  • yy position.

Returns a pointer to a L{AuiToolBarItem} if a tool is found, or None otherwise.

GetArtProvider()
Returns the current art provider being used.
GetAuiManager()
Returns the L{AuiManager} which manages the toolbar.
GetGripperVisible()
Returns whether the toolbar gripper is visible or not.
GetLabelSize(label)

Returns the standard size of a toolbar item.

Parameter:label – a test label.
GetOverflowRect()
Returns the rectangle of the overflow button.
GetOverflowState()
Returns the state of the overflow button.
GetOverflowVisible()
Returns whether the overflow button is visible or not.
GetToolBarFits()
Returns whether the L{AuiToolBar} size fits in a specified size.
GetToolBitmap(tool_id)

Returns the tool bitmap for the tool identified by tool_id.

Parameter:tool_id – the tool identifier.
GetToolBitmapSize()

Returns the size of bitmap that the toolbar expects to have. The default bitmap size is 16 by 15 pixels.

@note: Note that this is the size of the bitmap you pass to L{AddTool}, and not the eventual size of the tool button.

GetToolBorderPadding()
Returns the padding between the tool border and the label.
GetToolCount()
Returns the number of tools in the L{AuiToolBar}.
GetToolDropDown(tool_id)

Returns whether the toolbar item identified by tool_id has an associated drop down window menu or not.

Parameter:tool_id – the L{AuiToolBarItem} identifier.
GetToolEnabled(tool_id)

Returns whether the tool identified by tool_id is enabled or not.

Parameter:tool_id – the tool identifier.
GetToolFits(tool_id)

Returns whether the tool identified by tool_id fits into the toolbar or not.

Parameter:tool_id – the toolbar item identifier.
GetToolFitsByIndex(tool_idx)

Returns whether the tool identified by tool_idx fits into the toolbar or not.

Parameter:tool_idx – the toolbar item identifier.
GetToolIndex(tool_id)

Returns the position of the tool in the toolbar given its identifier.

Parameter:tool_id – the toolbar item identifier.
GetToolLabel(tool_id)

Returns the tool label for the tool identified by tool_id.

Parameter:tool_id – the tool identifier.
GetToolLongHelp(tool_id)

Returns the long help for the given tool.

Parameter:tool_id – the tool identifier.
GetToolPacking()
Returns the value used for spacing tools. The default value is 1.
GetToolPos(tool_id)

Returns the position of the tool in the toolbar given its identifier.

Parameter:tool_id – the toolbar item identifier.
GetToolProportion(tool_id)

Returns the tool proportion in the toolbar.

Parameter:tool_id – the L{AuiToolBarItem} identifier.
GetToolRect(tool_id)

Returns the toolbar item rectangle

Parameter:tool_id – the toolbar item identifier.
GetToolSeparation()
Returns the separator size for the toolbar.
GetToolShortHelp(tool_id)

Returns the short help for the given tool.

Parameter:tool_id – the tool identifier.
GetToolSticky(tool_id)

Returns whether the toolbar item identified by tool_id has a sticky behaviour or not.

Parameter:tool_id – the L{AuiToolBarItem} identifier.
GetToolTextOrientation()
Returns the label orientation for the toolbar items.
GetToolToggled(tool_id)

Returns whether a tool is toggled or not.

Parameter:tool_id – the toolbar item identifier.

@note: only applies to a tool that has been specified as a toggle tool.

GetWindowStyleFlag()
Overridden from wx.PyControl. Returns the window style flag.
OnCustomRender(dc, item, rect)

Handles custom render for single L{AuiToolBar} items. This method must be ocverridden to provide custom rendering of items.

Parameters:
  • dc – a L{wx.DC} device context;
  • item – an instance of L{AuiToolBarItem};
  • rect – the toolbar item rect.
OnEraseBackground(event)

Handles the wx.EVT_ERASE_BACKGROUND event for L{AuiToolBar}. This is intentionally empty, to reduce flicker.

Parameter:event – a L{wx.EraseEvent} event to be processed.
OnIdle(event)

Handles the wx.EVT_IDLE event for L{AuiToolBar}.

Parameter:event – a L{wx.IdleEvent} event to be processed.
OnLeaveWindow(event)

Handles the wx.EVT_LEAVE_WINDOW event for L{AuiToolBar}.

Parameter:event – a L{wx.MouseEvent} event to be processed.
OnLeftDown(event)

Handles the wx.EVT_LEFT_DOWN event for L{AuiToolBar}.

Parameter:event – a L{wx.MouseEvent} event to be processed.
OnLeftUp(event)

Handles the wx.EVT_LEFT_UP event for L{AuiToolBar}.

Parameter:event – a L{wx.MouseEvent} event to be processed.
OnMiddleDown(event)

Handles the wx.EVT_MIDDLE_DOWN event for L{AuiToolBar}.

Parameter:event – a L{wx.MouseEvent} event to be processed.
OnMiddleUp(event)

Handles the wx.EVT_MIDDLE_UP event for L{AuiToolBar}.

Parameter:event – a L{wx.MouseEvent} event to be processed.
OnMotion(event)

Handles the wx.EVT_MOTION event for L{AuiToolBar}.

Parameter:event – a L{wx.MouseEvent} event to be processed.
OnPaint(event)

Handles the wx.EVT_PAINT event for L{AuiToolBar}.

Parameter:event – a L{wx.PaintEvent} event to be processed.
OnRightDown(event)

Handles the wx.EVT_RIGHT_DOWN event for L{AuiToolBar}.

Parameter:event – a L{wx.MouseEvent} event to be processed.
OnRightUp(event)

Handles the wx.EVT_RIGHT_UP event for L{AuiToolBar}.

Parameter:event – a L{wx.MouseEvent} event to be processed.
OnSetCursor(event)

Handles the wx.EVT_SET_CURSOR event for L{AuiToolBar}.

Parameter:event – a L{wx.SetCursorEvent} event to be processed.
OnSize(event)

Handles the wx.EVT_SIZE event for L{AuiToolBar}.

Parameter:event – a L{wx.SizeEvent} event to be processed.
Realize()
Realizes the toolbar. This function should be called after you have added tools.
RefreshOverflowState()
Refreshes the overflow button.
SetArtProvider(art)

Instructs L{AuiToolBar} to use art provider specified by parameter art for all drawing calls. This allows plugable look-and-feel features. The previous art provider object, if any, will be deleted by L{AuiToolBar}.

Parameter:art – an art provider.
SetCustomOverflowItems(prepend, append)

Sets the two lists prepend and append as custom overflow items

Parameters:
  • prepend – a list of L{AuiToolBarItem}s to be prepended;
  • append – a list of L{AuiToolBarItem}s to be appended.
SetFont(font)

Overridden from wx.PyControl. Sets the L{AuiToolBar} font.

Parameter:font – a wx.Font object.
SetGripperVisible(visible)

Sets whether the toolbar gripper is visible or not.

Parameter:visible – True for a visible gripper, False otherwise.
SetHoverItem(pitem)

Sets a toolbar item to be currently hovered by the mouse.

Parameter:pitem – an instance of L{AuiToolBarItem}.
SetMargins(left=-1, right=-1, top=-1, bottom=-1)

Set the values to be used as margins for the toolbar.

Parameters:
  • left – the left toolbar margin;
  • right – the right toolbar margin;
  • top – the top toolbar margin;
  • bottom – the bottom toolbar margin.
SetMarginsSize(size)

Set the values to be used as margins for the toolbar.

Parameter:size – the margin size
SetMarginsXY(x, y)

Set the values to be used as margins for the toolbar.

Parameters:
  • x – left margin, right margin and inter-tool separation value;
  • y – top margin, bottom margin and inter-tool separation value.
SetOrientation(orientation)

Sets the toolbar orientation. Overridden by AuiManager.

Parameter:orientation – either wx.VERTICAL or wx.HORIZONTAL.
SetOverflowVisible(visible)

Sets whether the overflow button is visible or not.

Parameter:visible – True for a visible overflow button, False otherwise.
SetPressedItem(pitem)

Sets a toolbar item to be currently in a “pressed” state.

Parameter:pitem – an instance of L{AuiToolBarItem}.
SetToolBitmap(tool_id, bitmap)

Sets the tool bitmap for the tool identified by tool_id.

Parameters:
  • tool_id – the tool identifier;
  • bitmap – the new bitmap for the toolbar item.
SetToolBitmapSize(size)

Sets the default size of each tool bitmap. The default bitmap size is 16 by 15 pixels.

Parameter:size – the size of the bitmaps in the toolbar.

@note: This should be called to tell the toolbar what the tool bitmap size is. Call it before you add tools.

@note: Note that this is the size of the bitmap you pass to L{AddTool}, and not the eventual size of the tool button.

SetToolBorderPadding(padding)

Sets the padding between the tool border and the label.

Parameter:padding – the padding in pixels.
SetToolDisabledBitmap(tool_id, bitmap)

Sets the tool disabled bitmap for the tool identified by tool_id.

Parameters:
  • tool_id – the tool identifier;
  • bitmap – the new disabled bitmap for the toolbar item.
SetToolDropDown(tool_id, dropdown)

Assigns a drop down window menu to the toolbar item.

Parameters:
  • tool_id – the L{AuiToolBarItem} identifier;
  • dropdown – whether to assign a drop down menu or not.
SetToolLabel(tool_id, label)

Sets the tool label for the tool identified by tool_id.

Parameters:
  • tool_id – the tool identifier;
  • label – the new toolbar item label.
SetToolLongHelp(tool_id, help_string)

Sets the long help for the given tool.

Parameters:
  • tool_id – the tool identifier;
  • help_string – the string for the long help.
SetToolNormalBitmap(tool_id, bitmap)

Sets the tool bitmap for the tool identified by tool_id.

Parameters:
  • tool_id – the tool identifier;
  • bitmap – the new bitmap for the toolbar item.
SetToolPacking(packing)

Sets the value used for spacing tools. The default value is 1.

Parameter:packing – the value for packing.
SetToolProportion(tool_id, proportion)

Sets the tool proportion in the toolbar.

Parameters:
  • tool_id – the L{AuiToolBarItem} identifier;
  • proportion – the tool proportion in the toolbar.
SetToolSeparation(separation)

Sets the separator size for the toolbar.

Parameter:separation – the separator size in pixels.
SetToolShortHelp(tool_id, help_string)

Sets the short help for the given tool.

Parameters:
  • tool_id – the tool identifier;
  • help_string – the string for the short help.
SetToolSticky(tool_id, sticky)

Sets the toolbar item as sticky or non-sticky.

Parameters:
  • tool_id – the L{AuiToolBarItem} identifier;
  • sticky – whether the tool should be sticky or not.
SetToolTextOrientation(orientation)

Sets the label orientation for the toolbar items.

Parameter:orientation – the L{AuiToolBarItem} label orientation.
SetWindowStyleFlag(style)

Overridden from wx.PyControl. Sets the style of the window.

Parameter:style – the new window style.

@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.

ToggleTool(tool_id, state)

Toggles a tool on or off. This does not cause any event to get emitted.

Parameters:
  • tool_id – tool in question.
  • state – if True, toggles the tool on, otherwise toggles it off.

@note: only applies to a tool that has been specified as a toggle tool.

Table Of Contents

This Page