.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.ribbon.RibbonToolBar: ========================================================================================================================================== |phoenix_title| **wx.ribbon.RibbonToolBar** ========================================================================================================================================== A ribbon tool bar is similar to a traditional toolbar which has no labels. It contains one or more tool groups, each of which contains one or more tools. Each tool is represented by a (generally small, i.e. 16x15) bitmap. ^^ .. _RibbonToolBar-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`wx.ribbon.RibbonToolBarEvent` parameter. - EVT_RIBBONTOOLBAR_CLICKED: Triggered when the normal (non-dropdown) region of a tool on the tool bar is clicked. - EVT_RIBBONTOOLBAR_DROPDOWN_CLICKED: Triggered when the dropdown region of a tool on the tool bar is clicked. :meth:`wx.ribbon.RibbonToolBarEvent.PopupMenu` should be called by the event handler if it wants to display a popup menu (which is what most dropdown tools should be doing). ^^ | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class RibbonToolBar:
| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.ribbon.RibbonToolBar.__init__` Default constructor. :meth:`~wx.ribbon.RibbonToolBar.AddDropdownTool` Add a dropdown tool to the tool bar (simple version). :meth:`~wx.ribbon.RibbonToolBar.AddHybridTool` Add a hybrid tool to the tool bar (simple version). :meth:`~wx.ribbon.RibbonToolBar.AddSeparator` Add a separator to the tool bar. :meth:`~wx.ribbon.RibbonToolBar.AddToggleTool` Add a toggle tool to the tool bar (simple version). :meth:`~wx.ribbon.RibbonToolBar.AddTool` Add a tool to the tool bar (simple version). :meth:`~wx.ribbon.RibbonToolBar.ClearTools` Deletes all the tools in the toolbar. :meth:`~wx.ribbon.RibbonToolBar.Create` Create a tool bar in two-step tool bar construction. :meth:`~wx.ribbon.RibbonToolBar.DeleteTool` Removes the specified tool from the toolbar and deletes it. :meth:`~wx.ribbon.RibbonToolBar.DeleteToolByPos` This function behaves like :meth:`~RibbonToolBar.DeleteTool` but it deletes the tool at the specified position and not the one with the given id. :meth:`~wx.ribbon.RibbonToolBar.EnableTool` Enable or disable a single tool on the bar. :meth:`~wx.ribbon.RibbonToolBar.FindById` Returns a pointer to the tool opaque structure by `id` or ``None`` if no corresponding tool is found. :meth:`~wx.ribbon.RibbonToolBar.GetActiveTool` Returns the active item of the tool bar or ``None`` if there is none. :meth:`~wx.ribbon.RibbonToolBar.GetClassDefaultAttributes` :meth:`~wx.ribbon.RibbonToolBar.GetToolByPos` Return the opaque pointer corresponding to the given tool. :meth:`~wx.ribbon.RibbonToolBar.GetToolClientData` Get any client data associated with the tool. :meth:`~wx.ribbon.RibbonToolBar.GetToolCount` Returns the number of tools in the toolbar. :meth:`~wx.ribbon.RibbonToolBar.GetToolEnabled` Called to determine whether a tool is enabled (responds to user input). :meth:`~wx.ribbon.RibbonToolBar.GetToolHelpString` Returns the help string for the given tool. :meth:`~wx.ribbon.RibbonToolBar.GetToolId` Return the id associated to the tool opaque structure. :meth:`~wx.ribbon.RibbonToolBar.GetToolKind` Return the kind of the given tool. :meth:`~wx.ribbon.RibbonToolBar.GetToolPos` Returns the tool position in the toolbar, or ``NOT_FOUND`` if the tool is not found. :meth:`~wx.ribbon.RibbonToolBar.GetToolRect` Returns the tool's rect with coordinates relative to the toolbar's parent, or a default-constructed rect if the tool is not found. :meth:`~wx.ribbon.RibbonToolBar.GetToolState` Gets the on/off state of a toggle tool. :meth:`~wx.ribbon.RibbonToolBar.InsertDropdownTool` Insert a dropdown tool to the tool bar (simple version) as the specified position. :meth:`~wx.ribbon.RibbonToolBar.InsertHybridTool` Insert a hybrid tool to the tool bar (simple version) as the specified position. :meth:`~wx.ribbon.RibbonToolBar.InsertSeparator` Insert a separator to the tool bar at the specified position. :meth:`~wx.ribbon.RibbonToolBar.InsertToggleTool` Insert a toggle tool to the tool bar (simple version) as the specified position. :meth:`~wx.ribbon.RibbonToolBar.InsertTool` Insert a tool to the tool bar (simple version) as the specified position. :meth:`~wx.ribbon.RibbonToolBar.Realize` Calculate tool layouts and positions. :meth:`~wx.ribbon.RibbonToolBar.SetRows` Set the number of rows to distribute tool groups over. :meth:`~wx.ribbon.RibbonToolBar.SetToolClientData` Sets the client data associated with the tool. :meth:`~wx.ribbon.RibbonToolBar.SetToolDisabledBitmap` Sets the bitmap to be used by the tool with the given ``ID`` when the tool is in a disabled state. :meth:`~wx.ribbon.RibbonToolBar.SetToolHelpString` Sets the help string shown in tooltip for the given tool. :meth:`~wx.ribbon.RibbonToolBar.SetToolNormalBitmap` Sets the bitmap to be used by the tool with the given ``ID``. :meth:`~wx.ribbon.RibbonToolBar.ToggleTool` Set a toggle tool to the checked or unchecked state. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.ribbon.RibbonToolBar.ActiveTool` See :meth:`~wx.ribbon.RibbonToolBar.GetActiveTool` :attr:`~wx.ribbon.RibbonToolBar.ToolCount` See :meth:`~wx.ribbon.RibbonToolBar.GetToolCount` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.ribbon.RibbonToolBar(RibbonControl) **Possible constructors**:: RibbonToolBar() RibbonToolBar(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0) A ribbon tool bar is similar to a traditional toolbar which has no labels. .. method:: __init__(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **__init__** `(self)` Default constructor. With this constructor, :meth:`Create` should be called in order to create the tool bar. :html:`

` **__init__** `(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0)` Construct a ribbon tool bar with the given parameters. :param `parent`: Parent window for the tool bar (typically a :ref:`wx.ribbon.RibbonPanel`). :type `parent`: wx.Window :param `id`: An identifier for the toolbar. ``ID_ANY`` is taken to mean a default. :type `id`: wx.WindowID :param `pos`: Initial position of the tool bar. :type `pos`: wx.Point :param `size`: Initial size of the tool bar. :type `size`: wx.Size :param `style`: Tool bar style, currently unused. :type `style`: long :html:`

` .. method:: AddDropdownTool(self, tool_id, bitmap, help_string="") Add a dropdown tool to the tool bar (simple version). :param `tool_id`: :type `tool_id`: int :param `bitmap`: :type `bitmap`: wx.Bitmap :param `help_string`: :type `help_string`: string :rtype: `RibbonToolBarToolBase` .. seealso:: :meth:`AddTool` .. method:: AddHybridTool(self, tool_id, bitmap, help_string="") Add a hybrid tool to the tool bar (simple version). :param `tool_id`: :type `tool_id`: int :param `bitmap`: :type `bitmap`: wx.Bitmap :param `help_string`: :type `help_string`: string :rtype: `RibbonToolBarToolBase` .. seealso:: :meth:`AddTool` .. method:: AddSeparator(self) Add a separator to the tool bar. Separators are used to separate tools into groups. As such, a separator is not explicitly drawn, but is visually seen as the gap between tool groups. :rtype: `RibbonToolBarToolBase` .. method:: AddToggleTool(self, tool_id, bitmap, help_string) Add a toggle tool to the tool bar (simple version). :param `tool_id`: :type `tool_id`: int :param `bitmap`: :type `bitmap`: wx.Bitmap :param `help_string`: :type `help_string`: string :rtype: `RibbonToolBarToolBase` .. versionadded:: 2.9.4 .. seealso:: :meth:`AddTool` .. method:: AddTool(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **AddTool** `(self, tool_id, bitmap, help_string, kind=RIBBON_BUTTON_NORMAL)` Add a tool to the tool bar (simple version). :param `tool_id`: :type `tool_id`: int :param `bitmap`: :type `bitmap`: wx.Bitmap :param `help_string`: :type `help_string`: string :param `kind`: :type `kind`: wx.ribbon.RibbonButtonKind :rtype: `RibbonToolBarToolBase` :html:`

` **AddTool** `(self, tool_id, bitmap, bitmap_disabled=NullBitmap, help_string="", kind=RIBBON_BUTTON_NORMAL, clientData=None)` Add a tool to the tool bar. :param `tool_id`: ``ID`` of the new tool (used for event callbacks). :type `tool_id`: int :param `bitmap`: Bitmap to use as the foreground for the new tool. Does not have to be the same size as other tool bitmaps, but should be similar as otherwise it will look visually odd. :type `bitmap`: wx.Bitmap :param `bitmap_disabled`: Bitmap to use when the tool is disabled. If left as NullBitmap, then a bitmap will be automatically generated from `bitmap`. :type `bitmap_disabled`: wx.Bitmap :param `help_string`: The UI help string to associate with the new tool. :type `help_string`: string :param `kind`: The kind of tool to add. :type `kind`: wx.ribbon.RibbonButtonKind :param `clientData`: Client data to associate with the new tool. :type `clientData`: PyUserData :rtype: `RibbonToolBarToolBase` :returns: An opaque pointer which can be used only with other tool bar methods. .. seealso:: :meth:`AddDropdownTool` , :meth:`AddHybridTool` , :meth:`AddSeparator` , :meth:`InsertTool` :html:`

` .. method:: ClearTools(self) Deletes all the tools in the toolbar. .. versionadded:: 2.9.4 .. method:: Create(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=0) Create a tool bar in two-step tool bar construction. Should only be called when the default constructor is used, and arguments have the same meaning as in the full constructor. :param `parent`: :type `parent`: wx.Window :param `id`: :type `id`: wx.WindowID :param `pos`: :type `pos`: wx.Point :param `size`: :type `size`: wx.Size :param `style`: :type `style`: long :rtype: `bool` .. method:: DeleteTool(self, tool_id) Removes the specified tool from the toolbar and deletes it. :param `tool_id`: ``ID`` of the tool to delete. :type `tool_id`: int :rtype: `bool` :returns: ``True`` if the tool was deleted, ``False`` otherwise. .. versionadded:: 2.9.4 .. seealso:: :meth:`DeleteToolByPos` .. method:: DeleteToolByPos(self, pos) This function behaves like :meth:`DeleteTool` but it deletes the tool at the specified position and not the one with the given id. Useful to delete separators. :param `pos`: :type `pos`: int :rtype: `bool` .. versionadded:: 2.9.4 .. method:: EnableTool(self, tool_id, enable=True) Enable or disable a single tool on the bar. :param `tool_id`: ``ID`` of the tool to enable or disable. :type `tool_id`: int :param `enable`: ``True`` to enable the tool, ``False`` to disable it. :type `enable`: bool .. versionadded:: 2.9.4 .. method:: FindById(self, tool_id) Returns a pointer to the tool opaque structure by `id` or ``None`` if no corresponding tool is found. :param `tool_id`: :type `tool_id`: int :rtype: `RibbonToolBarToolBase` .. versionadded:: 2.9.4 .. method:: GetActiveTool(self) Returns the active item of the tool bar or ``None`` if there is none. The active tool is the one being clicked. :rtype: `RibbonToolBarToolBase` .. versionadded:: 4.1/wxWidgets-3.1.7 .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL) :param `variant`: :type `variant`: wx.WindowVariant :rtype: `VisualAttributes` .. method:: GetToolByPos(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **GetToolByPos** `(self, pos)` Return the opaque pointer corresponding to the given tool. :param `pos`: :type `pos`: int :rtype: `RibbonToolBarToolBase` :returns: an opaque pointer, ``None`` if is a separator or not found. .. versionadded:: 2.9.4 :html:`

` **GetToolByPos** `(self, x, y)` Returns the opaque pointer for the tool at the given coordinates, which are relative to the toolbar's parent. :param `x`: :type `x`: int :param `y`: :type `y`: int :rtype: `RibbonToolBarToolBase` :returns: an opaque pointer, ``None`` if is not found. .. versionadded:: 4.1/wxWidgets-3.1.5 :html:`

` .. method:: GetToolClientData(self, tool_id) Get any client data associated with the tool. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :rtype: `PyUserData` :returns: Client data, or ``None`` if there is none. .. versionadded:: 2.9.4 .. method:: GetToolCount(self) Returns the number of tools in the toolbar. :rtype: `int` .. versionadded:: 2.9.4 .. method:: GetToolEnabled(self, tool_id) Called to determine whether a tool is enabled (responds to user input). :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :rtype: `bool` :returns: ``True`` if the tool is enabled, ``False`` otherwise. .. versionadded:: 2.9.4 .. seealso:: :meth:`EnableTool` .. method:: GetToolHelpString(self, tool_id) Returns the help string for the given tool. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :rtype: `string` .. versionadded:: 2.9.4 .. method:: GetToolId(self, tool) Return the id associated to the tool opaque structure. The structure pointer must not be ``None``. :param `tool`: :type `tool`: RibbonToolBarToolBase :rtype: `int` .. versionadded:: 2.9.4 .. method:: GetToolKind(self, tool_id) Return the kind of the given tool. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :rtype: :ref:`wx.ribbon.RibbonButtonKind` .. versionadded:: 2.9.4 .. method:: GetToolPos(self, tool_id) Returns the tool position in the toolbar, or ``NOT_FOUND`` if the tool is not found. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :rtype: `int` .. versionadded:: 2.9.4 .. method:: GetToolRect(self, tool_id) Returns the tool's rect with coordinates relative to the toolbar's parent, or a default-constructed rect if the tool is not found. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :rtype: `Rect` .. versionadded:: 4.1/wxWidgets-3.1.5 .. method:: GetToolState(self, tool_id) Gets the on/off state of a toggle tool. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :rtype: `bool` :returns: ``True`` if the tool is toggled on, ``False`` otherwise. .. versionadded:: 2.9.4 .. seealso:: :meth:`ToggleTool` .. method:: InsertDropdownTool(self, pos, tool_id, bitmap, help_string="") Insert a dropdown tool to the tool bar (simple version) as the specified position. :param `pos`: :type `pos`: int :param `tool_id`: :type `tool_id`: int :param `bitmap`: :type `bitmap`: wx.Bitmap :param `help_string`: :type `help_string`: string :rtype: `RibbonToolBarToolBase` .. versionadded:: 2.9.4 .. seealso:: :meth:`AddDropdownTool` , :meth:`InsertTool` .. method:: InsertHybridTool(self, pos, tool_id, bitmap, help_string="") Insert a hybrid tool to the tool bar (simple version) as the specified position. :param `pos`: :type `pos`: int :param `tool_id`: :type `tool_id`: int :param `bitmap`: :type `bitmap`: wx.Bitmap :param `help_string`: :type `help_string`: string :rtype: `RibbonToolBarToolBase` .. versionadded:: 2.9.4 .. seealso:: :meth:`AddHybridTool` , :meth:`InsertTool` .. method:: InsertSeparator(self, pos) Insert a separator to the tool bar at the specified position. :param `pos`: :type `pos`: int :rtype: `RibbonToolBarToolBase` .. versionadded:: 2.9.4 .. seealso:: :meth:`AddSeparator` , :meth:`InsertTool` .. method:: InsertToggleTool(self, pos, tool_id, bitmap, help_string="") Insert a toggle tool to the tool bar (simple version) as the specified position. :param `pos`: :type `pos`: int :param `tool_id`: :type `tool_id`: int :param `bitmap`: :type `bitmap`: wx.Bitmap :param `help_string`: :type `help_string`: string :rtype: `RibbonToolBarToolBase` .. versionadded:: 2.9.4 .. seealso:: :meth:`AddToggleTool` , :meth:`InsertTool` .. method:: InsertTool(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **InsertTool** `(self, pos, tool_id, bitmap, help_string, kind=RIBBON_BUTTON_NORMAL)` Insert a tool to the tool bar (simple version) as the specified position. :param `pos`: :type `pos`: int :param `tool_id`: :type `tool_id`: int :param `bitmap`: :type `bitmap`: wx.Bitmap :param `help_string`: :type `help_string`: string :param `kind`: :type `kind`: wx.ribbon.RibbonButtonKind :rtype: `RibbonToolBarToolBase` .. versionadded:: 2.9.4 .. seealso:: :meth:`InsertTool` :html:`

` **InsertTool** `(self, pos, tool_id, bitmap, bitmap_disabled=NullBitmap, help_string="", kind=RIBBON_BUTTON_NORMAL, clientData=None)` Insert a tool to the tool bar at the specified position. :param `pos`: Position of the new tool (number of tools and separators from the beginning of the toolbar). :type `pos`: int :param `tool_id`: ``ID`` of the new tool (used for event callbacks). :type `tool_id`: int :param `bitmap`: Bitmap to use as the foreground for the new tool. Does not have to be the same size as other tool bitmaps, but should be similar as otherwise it will look visually odd. :type `bitmap`: wx.Bitmap :param `bitmap_disabled`: Bitmap to use when the tool is disabled. If left as NullBitmap, then a bitmap will be automatically generated from `bitmap`. :type `bitmap_disabled`: wx.Bitmap :param `help_string`: The UI help string to associate with the new tool. :type `help_string`: string :param `kind`: The kind of tool to add. :type `kind`: wx.ribbon.RibbonButtonKind :param `clientData`: Client data to associate with the new tool. :type `clientData`: PyUserData :rtype: `RibbonToolBarToolBase` :returns: An opaque pointer which can be used only with other tool bar methods. .. versionadded:: 2.9.4 .. seealso:: :meth:`InsertDropdownTool` , :meth:`InsertHybridTool` , :meth:`InsertSeparator` :html:`

` .. method:: Realize(self) Calculate tool layouts and positions. Must be called after tools are added to the tool bar, as otherwise the newly added tools will not be displayed. :rtype: `bool` .. method:: SetRows(self, nMin, nMax=-1) Set the number of rows to distribute tool groups over. Tool groups can be distributed over a variable number of rows. The way in which groups are assigned to rows is not specified, and the order of groups may change, but they will be distributed in such a way as to minimise the overall size of the tool bar. :param `nMin`: The minimum number of rows to use. :type `nMin`: int :param `nMax`: The maximum number of rows to use (defaults to nMin). :type `nMax`: int .. method:: SetToolClientData(self, tool_id, clientData) Sets the client data associated with the tool. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :param `clientData`: The client data to use. :type `clientData`: PyUserData .. versionadded:: 2.9.4 .. method:: SetToolDisabledBitmap(self, tool_id, bitmap) Sets the bitmap to be used by the tool with the given ``ID`` when the tool is in a disabled state. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :param `bitmap`: Bitmap to use for disabled tools. :type `bitmap`: wx.Bitmap .. versionadded:: 2.9.4 .. method:: SetToolHelpString(self, tool_id, helpString) Sets the help string shown in tooltip for the given tool. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :param `helpString`: A string for the help. :type `helpString`: string .. versionadded:: 2.9.4 .. seealso:: :meth:`GetToolHelpString` .. method:: SetToolNormalBitmap(self, tool_id, bitmap) Sets the bitmap to be used by the tool with the given ``ID``. :param `tool_id`: ``ID`` of the tool in question, as passed to :meth:`AddTool` . :type `tool_id`: int :param `bitmap`: Bitmap to use for normals tools. :type `bitmap`: wx.Bitmap .. versionadded:: 2.9.4 .. method:: ToggleTool(self, tool_id, checked) Set a toggle tool to the checked or unchecked state. :param `tool_id`: ``ID`` of the toggle tool to manipulate. :type `tool_id`: int :param `checked`: ``True`` to set the tool to the toggled/pressed/checked state, ``False`` to set it to the untoggled/unpressed/unchecked state. :type `checked`: bool .. versionadded:: 2.9.4 .. attribute:: ActiveTool See :meth:`~wx.ribbon.RibbonToolBar.GetActiveTool` .. attribute:: ToolCount See :meth:`~wx.ribbon.RibbonToolBar.GetToolCount`