A ToolPalette is used to display a large number of items. It is similar to a Toolbar, however is tailored for use in applications which require more features accessible to the user such as image editing.


The ToolPalette can be constructed using the following:

toolpalette = Gtk.ToolPalette()


In some cases, it may be required to only display one of the ToolItemGroup objects at any one time with:

toolpalette.set_exclusive(toolitemgroup, exclusive)

The toolitemgroup parameter should be set to a :doc:toolitemgroup` identifying which should be set to exclusive status. When the *exclusive* parameter is set to ``True, the ToolItemGroup will display and all other open groups will be closed.

To expand a ToolItemGroup programatically use:

toolpalette.set_expand(toolitemgroup, expand)

Again, the toolitemgroup parameter is a ToolItemGroup which is to be expanded. When the expand property is set to True, the items within the group will be opened.

Groups can be set or changed with:

toolpalette.set_group_position(group, position)

The group parameter must be set to a ToolItemGroup which is to be configured. The position value should be an integer value indicating the location of the group within the ToolPalette, with 0 indicating the first position.

The ToolPalette by default takes the system style for Toolbars. This can be configured to:


The style parameter should be set to one of the following; Gtk.ToolbarStyle.ICONS, Gtk.ToolbarStyle.TEXT, Gtk.ToolbarStyle.BOTH, Gtk.ToolbarStyle.BOTH_HORIZ. When using Gtk.ToolbarStyle.ICONS or Gtk.ToolbarStyle.TEXT only icons or text are displayed. Gtk.ToolbarStyle.BOTH displays icons and text, with the text positioned beneath the icon. Gtk.ToolbarStyle.BOTH_HORIZ displays text to the left of the icon.


It is highly recommended not to set a style and to use whichever the GTK+ global setting specifies, for both consistency and usability reasons.

Icon sizes within the ToolPalette can be configured with:


The icon_size argument must be set to one of the following values; Gtk.IconSize.INVALID, Gtk.IconSize.MENU, Gtk.IconSize.SMALL_TOOLBAR, Gtk.IconSize.LARGE_TOOLBAR, Gtk.IconSize.BUTTON, Gtk.IconSize.DND, or Gtk.IconSize.DIALOG. The ToolPalette takes the global size setting by default.

Customisation of the direction in which items are displayed in the ToolPalette can be made with:


The orientation parameter by default is Gtk.Orientation.VERTICAL in which all groups of added vertically, however Gtk.Orientation.HORIZONTAL can also be used to add groups horizontally.


Below is an example of a ToolPalette:

#!/usr/bin/env python3

from gi.repository import Gtk

class ToolPalette(Gtk.Window):
    def __init__(self):
        self.set_default_size(200, 200)
        self.connect("destroy", Gtk.main_quit)

        toolpalette = Gtk.ToolPalette()

        toolitemgroup = Gtk.ToolItemGroup(label="Group 1")

        toolbutton = Gtk.ToolButton()
        toolitemgroup.insert(toolbutton, 0)
        toolbutton = Gtk.ToolButton()
        toolitemgroup.insert(toolbutton, 1)
        toolbutton = Gtk.ToolButton()
        toolitemgroup.insert(toolbutton, 2)

        toolitemgroup = Gtk.ToolItemGroup(label="Group 2")

        toolbutton = Gtk.ToolButton()
        toolitemgroup.insert(toolbutton, 0)
        toolbutton = Gtk.ToolButton()
        toolitemgroup.insert(toolbutton, 1)

window = ToolPalette()


Download: ToolPalette