Inheritance diagram for wx.ToolBar:
The name wx.ToolBar is defined to be a synonym for one of the following classes:
See also
Window Style | Description |
---|---|
wx.TB_FLAT | Gives the toolbar a flat look (Windows and GTK only). |
wx.TB_DOCKABLE | Makes the toolbar floatable and dockable (GTK only). |
wx.TB_HORIZONTAL | Specifies horizontal layout (default). |
wx.TB_VERTICAL | Specifies vertical layout. |
wx.TB_TEXT | Shows the text in the toolbar buttons; by default only icons are shown. |
wx.TB_NOICONS | Specifies no icons in the toolbar buttons; by default they are shown. |
wx.TB_NODIVIDER | Specifies no divider (border) above the toolbar (Windows only). |
wx.TB_NOALIGN | Specifies no alignment with the parent window (Windows only, not very useful). |
wx.TB_HORZ_LAYOUT | Shows the text and the icons alongside, not vertically stacked (Windows and GTK 2 only). This style must be used with wx.TB_TEXT. |
wx.TB_HORZ_TEXT | Combination of wx.TB_HORZ_LAYOUT and wx.TB_TEXT. |
wx.TB_NO_TOOLTIPS | Don’t show the short help tooltips for the tools when the mouse hovers over them. |
wx.TB_BOTTOM | Align the toolbar at the bottom of parent window. |
wx.TB_RIGHT | Align the toolbar at the right side of parent window. |
You may also create a toolbar that is managed by the frame, by calling wx.Frame.CreateToolBar. Under Pocket PC, you should always use this function for creating the toolbar to be managed by the frame, so that wxWidgets can use a combined menubar and toolbar. Where you manage your own toolbars, create a wx.ToolBar as usual.
The meaning of a “separator” is a vertical line under Windows and simple space under GTK+.
wx.ToolBar95: Note that this toolbar paints tools to reflect system-wide colours. If you use more than 16 colours in your tool bitmaps, you may wish to suppress this behaviour, otherwise system colours in your bitmaps will inadvertently be mapped to system colours. To do this, set the msw.remap system option before creating the toolbar:
wx.SystemOptions.SetOption("msw.remap", 0)
If you wish to use 32-bit images (which include an alpha channel for transparency) use:
wx.SystemOptions.SetOption("msw.remap", 2)
Then colour remapping is switched off, and a transparent background used. But only use this option under Windows XP with true colour:
theApp.GetComCtl32Version() >= 600 and wx.DisplayDepth() >= 32
The toolbar class emits menu commands in the same way that a frame menubar does, so you can use one wx.EVT_MENU event for both a menu item and a toolbar button. The event handler functions take a wx.CommandEvent argument. For most event, the identifier of the tool is passed, but for wx.EVT_TOOL_ENTER the toolbar window identifier is passed and the tool identifier is retrieved from the wx.CommandEvent.
This is because the identifier may be -1 when the mouse moves off a tool, and -1 is not allowed as an identifier in the event system.
Event Name | Description |
---|---|
wx.EVT_TOOL(id, func) | Process a wx.wxEVT_COMMAND_TOOL_CLICKED event (a synonym for wx.wxEVT_COMMAND_MENU_SELECTED). Pass the id of the tool. |
wx.EVT_MENU(id, func) | The same as EVT_TOOL. |
wx.EVT_TOOL_RANGE(id1, id2, func) | Process a wx.wxEVT_COMMAND_TOOL_CLICKED event for a range of identifiers. Pass the ids of the tools. |
wx.EVT_MENU_RANGE(id1, id2, func) | The same as EVT_TOOL_RANGE. |
wx.EVT_TOOL_RCLICKED(id, func) | Process a wx.wxEVT_COMMAND_TOOL_RCLICKED event. Pass the id of the tool. |
wx.EVT_TOOL_RCLICKED_RANGE(id1, id2, func) | Process a wx.wxEVT_COMMAND_TOOL_RCLICKED event for a range of ids. Pass the ids of the tools. |
wx.EVT_TOOL_ENTER(id, func) | Process a wx.wxEVT_COMMAND_TOOL_ENTER event. Pass the id of the toolbar itself. The value of wx.CommandEvent.GetSelection is the tool id, or -1 if the mouse cursor has moved off a tool. |
Constructs a toolbar.
Parameters:
Returns:
Adds a new check (or toggle) tool to the toolbar.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
See also
Adds a new check (or toggle) tool to the toolbar.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
See also
Adds any control to the toolbar, typically e.g. a combobox.
Parameters:
Returns:
bool
Adds a new label tool to the toolbar.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
See also
Add a radio tool, i.e. a tool which can be toggled and releases any other toggled radio tools in the same group when it happens.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
See also
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.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
See also
See also
Old way to add a new tool to the toolbar.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
Old way to add a new tool to the toolbar.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
See also
AddSeparator, AddCheckTool, AddRadioTool, InsertTool, DeleteTool, Realize
Adds a wx.ToolBarToolBase item to the toolbar.
Parameters:
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 RemoveTool instead.
Returns True if the tool was deleted, False otherwise.
Parameters:
Returns:
bool
Note
Note that it is unnecessary to call Realize for the change to take place, it will happen immediately.
See also
This function behaves like DeleteTool but it deletes the tool at the specified position and not the one with the given id.
Parameters:
Returns:
bool
Enables or disables the tool.
Parameters:
Note
Some implementations will change the visible state of the tool to indicate that it is disabled.
See also
Returns a pointer to the tool identified by id or None if no corresponding tool is found.
Parameters:
Returns:
wxToolBarToolBase
Returns a pointer to the control identified by id or None if no corresponding control is found.
Parameters:
Returns:
Finds a tool for the given mouse position.
Parameters:
Returns:
wx.ToolBarToolBase
Note
Currently not implemented in wxGTK (always returns None there).
Returns the left/right and top/bottom margins, which are also used for inter-toolspacing.
Returns:
See also
Returns the size of bitmap that the toolbar expects to have. The default bitmap size is 16 by 15 pixels.
Returns:
Note
Note that this is the size of the bitmap you pass to AddTool, and not the eventual size of the tool button.
See also
Get any client data associated with the tool.
Parameters:
Returns:
Called to determine whether a tool is enabled (responds to user input).
Parameters:
Returns:
bool
See also
Returns the long help for the given tool.
Parameters:
Returns:
string
See also
Returns the value used for packing tools.
Returns:
int
See also
Returns the tool position in the toolbar, or wx.NOT_FOUND if the tool is not found.
Parameters:
Returns:
int
Returns the default separator size.
Returns:
int
See also
Returns the short help for the given tool.
Parameters:
Returns:
string
See also
Returns the size of a whole button, which is usually larger than a tool bitmap because of added 3D effects.
Returns:
See also
Gets the on/off state of a toggle tool.
Parameters:
Returns:
bool
See also
Returns the number of tools in the toolbar.
Returns:
int
Inserts the control into the toolbar at the given position.
You must call Realize for the change to take place.
Parameters:
Returns:
wx.ToolBarToolBase
See also
Inserts a new label tool to the toolbar at the specified position.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
See also
Inserts the separator into the toolbar at the given position. You must call Realize for the change to take place.
Returns:
wx.ToolBarToolBase
See also
Old way to insert a new tool to the toolbar.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
Old way to insert a new tool to the toolbar.
Parameters:
Returns:
wx.ToolBarToolBase
Note
After you have added tools to a toolbar, you must call Realize in order to have the tools appear
See also
AddSeparator, AddCheckTool, AddRadioTool, InsertTool, DeleteTool, Realize
Inserts a wx.ToolBarToolBase item to the toolbar in the specified position.
Parameters:
This function should be called after you have added tools.
Returns:
bool
Removes the given tool from the toolbar but doesn’t delete it.
This allows to insert/add this tool back to this (or another) toolbar later.
Parameters:
Returns:
wx.ToolBarToolBase
Note
Note that it is unnecessary to call Realize for the change to take place, it will happen immediately.
See also
Set the values to be used as margins for the toolbar.
Parameters:
Note
This must be called before the tools are added if absolute positioning is to be used, and the default (zero-size) margins are to be overridden.
See also
Set the values to be used as margins for the toolbar.
Parameters:
Note
This must be called before the tools are added if absolute positioning is to be used, and the default (zero-size) margins are to be overridden.
See also
Sets the default size of each tool bitmap. The default bitmap size is 16 by 15 pixels.
Parameters:
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 AddTool, and not the eventual size of the tool button.
Sets the client data associated with the tool.
Parameters:
Sets the bitmap to be used by the tool with the given id when the tool is in a disabled state. This can only be used on Button tools, not controls.
Parameters:
Note
The native toolbar classes on the main platforms all synthesize the disabled bitmap from the normal bitmap, so this function will have no effect on those platforms.
Sets the long help for the given tool.
Parameters:
Note
You might use the long help for displaying the tool purpose on the wx.StatusBar.
See also
Sets the bitmap to be used by the tool with the given id. This can only be used on Button tools, not controls.
Parameters:
Sets the value used for spacing tools. The default value is 1.
Parameters:
Note
The packing is used for spacing in the vertical direction if the toolbar is horizontal, and for spacing in the horizontal direction if the toolbar is vertical.
See also
Sets the default separator size. The default value is 5.
Parameters:
See also
Sets the short help for the given tool.
Parameters:
Note
An application might use short help for identifying the tool purpose in a tooltip.
Toggles a tool on or off. This does not cause any event to get emitted.
Parameters:
Note
Only applies to a tool that has been specified as a toggle tool.