Gtk.ToolItem

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Activatable Gtk.Activatable GObject.GInterface->Gtk.Activatable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.ToolItem Gtk.ToolItem Gtk.Activatable->Gtk.ToolItem Gtk.Bin Gtk.Bin Gtk.Bin->Gtk.ToolItem Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget->Gtk.Container

Subclasses:

Gtk.SeparatorToolItem, Gtk.ToolButton

Methods

Inherited:

Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Activatable (6)

Structs:

Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new ()

get_ellipsize_mode ()

get_expand ()

get_homogeneous ()

get_icon_size ()

get_is_important ()

get_orientation ()

get_proxy_menu_item (menu_item_id)

get_relief_style ()

get_text_alignment ()

get_text_orientation ()

get_text_size_group ()

get_toolbar_style ()

get_use_drag_window ()

get_visible_horizontal ()

get_visible_vertical ()

rebuild_menu ()

retrieve_proxy_menu_item ()

set_expand (expand)

set_homogeneous (homogeneous)

set_is_important (is_important)

set_proxy_menu_item (menu_item_id, menu_item)

set_tooltip_markup (markup)

set_tooltip_text (text)

set_use_drag_window (use_drag_window)

set_visible_horizontal (visible_horizontal)

set_visible_vertical (visible_vertical)

toolbar_reconfigured ()

Virtual Methods

Inherited:

Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.Activatable (2)

do_create_menu_proxy ()

do_toolbar_reconfigured ()

Properties

Inherited:

Gtk.Container (3), Gtk.Widget (39), Gtk.Activatable (2)

Name

Type

Flags

Short Description

is-important

bool

r/w/en

Whether the toolbar item is considered important. When True, toolbar buttons show text in Gtk.ToolbarStyle.BOTH_HORIZ mode

visible-horizontal

bool

r/w/en

Whether the toolbar item is visible when the toolbar is in a horizontal orientation.

visible-vertical

bool

r/w/en

Whether the toolbar item is visible when the toolbar is in a vertical orientation.

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Name

Short Description

create-menu-proxy

This signal is emitted when the toolbar needs information from tool_item about whether the item should appear in the toolbar overflow menu.

toolbar-reconfigured

This signal is emitted when some property of the toolbar that the item is a child of changes.

Fields

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)

Name

Type

Access

Description

parent

Gtk.Bin

r

Class Details

class Gtk.ToolItem(**kwargs)
Bases:

Gtk.Bin, Gtk.Activatable

Abstract:

No

Structure:

Gtk.ToolItemClass

Gtk.ToolItems are widgets that can appear on a toolbar. To create a toolbar item that contain something else than a button, use Gtk.ToolItem.new(). Use Gtk.Container.add() to add a child widget to the tool item.

For toolbar items that contain buttons, see the Gtk.ToolButton, Gtk.ToggleToolButton and Gtk.RadioToolButton classes.

See the Gtk.Toolbar class for a description of the toolbar widget, and Gtk.ToolShell for a description of the tool shell interface.

classmethod new()[source]
Returns:

the new Gtk.ToolItem

Return type:

Gtk.ToolItem

Creates a new Gtk.ToolItem

New in version 2.4.

get_ellipsize_mode()[source]
Returns:

a Pango.EllipsizeMode indicating how text in self should be ellipsized.

Return type:

Pango.EllipsizeMode

Returns the ellipsize mode used for self. Custom subclasses of Gtk.ToolItem should call this function to find out how text should be ellipsized.

New in version 2.20.

get_expand()[source]
Returns:

True if self is allocated extra space.

Return type:

bool

Returns whether self is allocated extra space. See Gtk.ToolItem.set_expand().

New in version 2.4.

get_homogeneous()[source]
Returns:

True if the item is the same size as other homogeneous items.

Return type:

bool

Returns whether self is the same size as other homogeneous items. See Gtk.ToolItem.set_homogeneous().

New in version 2.4.

get_icon_size()[source]
Returns:

a Gtk.IconSize indicating the icon size used for self

Return type:

int

Returns the icon size used for self. Custom subclasses of Gtk.ToolItem should call this function to find out what size icons they should use.

New in version 2.4.

get_is_important()[source]
Returns:

True if self is considered important.

Return type:

bool

Returns whether self is considered important. See Gtk.ToolItem.set_is_important()

New in version 2.4.

get_orientation()[source]
Returns:

a Gtk.Orientation indicating the orientation used for self

Return type:

Gtk.Orientation

Returns the orientation used for self. Custom subclasses of Gtk.ToolItem should call this function to find out what size icons they should use.

New in version 2.4.

get_proxy_menu_item(menu_item_id)[source]
Parameters:

menu_item_id (str) – a string used to identify the menu item

Returns:

The Gtk.MenuItem passed to Gtk.ToolItem.set_proxy_menu_item(), if the menu_item_ids match.

Return type:

Gtk.Widget or None

If menu_item_id matches the string passed to Gtk.ToolItem.set_proxy_menu_item() return the corresponding Gtk.MenuItem.

Custom subclasses of Gtk.ToolItem should use this function to update their menu item when the Gtk.ToolItem changes. That the menu_item_ids must match ensures that a Gtk.ToolItem will not inadvertently change a menu item that they did not create.

New in version 2.4.

get_relief_style()[source]
Returns:

a Gtk.ReliefStyle indicating the relief style used for self.

Return type:

Gtk.ReliefStyle

Returns the relief style of self. See Gtk.Button.set_relief(). Custom subclasses of Gtk.ToolItem should call this function in the handler of the #GtkToolItem::toolbar_reconfigured signal to find out the relief style of buttons.

New in version 2.4.

get_text_alignment()[source]
Returns:

a float indicating the horizontal text alignment used for self

Return type:

float

Returns the text alignment used for self. Custom subclasses of Gtk.ToolItem should call this function to find out how text should be aligned.

New in version 2.20.

get_text_orientation()[source]
Returns:

a Gtk.Orientation indicating the text orientation used for self

Return type:

Gtk.Orientation

Returns the text orientation used for self. Custom subclasses of Gtk.ToolItem should call this function to find out how text should be orientated.

New in version 2.20.

get_text_size_group()[source]
Returns:

a Gtk.SizeGroup

Return type:

Gtk.SizeGroup

Returns the size group used for labels in self. Custom subclasses of Gtk.ToolItem should call this function and use the size group for labels.

New in version 2.20.

get_toolbar_style()[source]
Returns:

A Gtk.ToolbarStyle indicating the toolbar style used for self.

Return type:

Gtk.ToolbarStyle

Returns the toolbar style used for self. Custom subclasses of Gtk.ToolItem should call this function in the handler of the GtkToolItem::toolbar_reconfigured signal to find out in what style the toolbar is displayed and change themselves accordingly

Possibilities are:

New in version 2.4.

get_use_drag_window()[source]
Returns:

True if self uses a drag window.

Return type:

bool

Returns whether self has a drag window. See Gtk.ToolItem.set_use_drag_window().

New in version 2.4.

get_visible_horizontal()[source]
Returns:

True if self is visible on toolbars that are docked horizontally.

Return type:

bool

Returns whether the self is visible on toolbars that are docked horizontally.

New in version 2.4.

get_visible_vertical()[source]
Returns:

Whether self is visible when the toolbar is docked vertically

Return type:

bool

Returns whether self is visible when the toolbar is docked vertically. See Gtk.ToolItem.set_visible_vertical().

New in version 2.4.

rebuild_menu()[source]

Calling this function signals to the toolbar that the overflow menu item for self has changed. If the overflow menu is visible when this function it called, the menu will be rebuilt.

The function must be called when the tool item changes what it will do in response to the Gtk.ToolItem ::create-menu-proxy signal.

New in version 2.6.

retrieve_proxy_menu_item()[source]
Returns:

The Gtk.MenuItem that is going to appear in the overflow menu for self.

Return type:

Gtk.Widget

Returns the Gtk.MenuItem that was last set by Gtk.ToolItem.set_proxy_menu_item(), ie. the Gtk.MenuItem that is going to appear in the overflow menu.

New in version 2.4.

set_expand(expand)[source]
Parameters:

expand (bool) – Whether self is allocated extra space

Sets whether self is allocated extra space when there is more room on the toolbar then needed for the items. The effect is that the item gets bigger when the toolbar gets bigger and smaller when the toolbar gets smaller.

New in version 2.4.

set_homogeneous(homogeneous)[source]
Parameters:

homogeneous (bool) – whether self is the same size as other homogeneous items

Sets whether self is to be allocated the same size as other homogeneous items. The effect is that all homogeneous items will have the same width as the widest of the items.

New in version 2.4.

set_is_important(is_important)[source]
Parameters:

is_important (bool) – whether the tool item should be considered important

Sets whether self should be considered important. The Gtk.ToolButton class uses this property to determine whether to show or hide its label when the toolbar style is Gtk.ToolbarStyle.BOTH_HORIZ. The result is that only tool buttons with the “is_important” property set have labels, an effect known as “priority text”

New in version 2.4.

set_proxy_menu_item(menu_item_id, menu_item)[source]
Parameters:

Sets the Gtk.MenuItem used in the toolbar overflow menu. The menu_item_id is used to identify the caller of this function and should also be used with Gtk.ToolItem.get_proxy_menu_item().

See also Gtk.ToolItem ::create-menu-proxy.

New in version 2.4.

set_tooltip_markup(markup)[source]
Parameters:

markup (str) – markup text to be used as tooltip for self

Sets the markup text to be displayed as tooltip on the item. See Gtk.Widget.set_tooltip_markup().

New in version 2.12.

set_tooltip_text(text)[source]
Parameters:

text (str) – text to be used as tooltip for self

Sets the text to be displayed as tooltip on the item. See Gtk.Widget.set_tooltip_text().

New in version 2.12.

set_use_drag_window(use_drag_window)[source]
Parameters:

use_drag_window (bool) – Whether self has a drag window.

Sets whether self has a drag window. When True the toolitem can be used as a drag source through Gtk.Widget.drag_source_set(). When self has a drag window it will intercept all events, even those that would otherwise be sent to a child of self.

New in version 2.4.

set_visible_horizontal(visible_horizontal)[source]
Parameters:

visible_horizontal (bool) – Whether self is visible when in horizontal mode

Sets whether self is visible when the toolbar is docked horizontally.

New in version 2.4.

set_visible_vertical(visible_vertical)[source]
Parameters:

visible_vertical (bool) – whether self is visible when the toolbar is in vertical mode

Sets whether self is visible when the toolbar is docked vertically. Some tool items, such as text entries, are too wide to be useful on a vertically docked toolbar. If visible_vertical is False self will not appear on toolbars that are docked vertically.

New in version 2.4.

toolbar_reconfigured()[source]

Emits the signal #GtkToolItem::toolbar_reconfigured on self. Gtk.Toolbar and other Gtk.ToolShell implementations use this function to notify children, when some aspect of their configuration changes.

New in version 2.14.

do_create_menu_proxy() virtual
Return type:

bool

Signal emitted when the toolbar needs information from tool_item about whether the item should appear in the toolbar overflow menu.

do_toolbar_reconfigured() virtual

Emits the signal #GtkToolItem::toolbar_reconfigured on tool_item. Gtk.Toolbar and other Gtk.ToolShell implementations use this function to notify children, when some aspect of their configuration changes.

New in version 2.14.

Signal Details

Gtk.ToolItem.signals.create_menu_proxy(tool_item)
Signal Name:

create-menu-proxy

Flags:

RUN_LAST

Parameters:

tool_item (Gtk.ToolItem) – The object which received the signal

Returns:

True if the signal was handled, False if not

Return type:

bool

This signal is emitted when the toolbar needs information from tool_item about whether the item should appear in the toolbar overflow menu. In response the tool item should either

The toolbar may cache the result of this signal. When the tool item changes how it will respond to this signal it must call Gtk.ToolItem.rebuild_menu() to invalidate the cache and ensure that the toolbar rebuilds its overflow menu.

Gtk.ToolItem.signals.toolbar_reconfigured(tool_item)
Signal Name:

toolbar-reconfigured

Flags:

RUN_LAST

Parameters:

tool_item (Gtk.ToolItem) – The object which received the signal

This signal is emitted when some property of the toolbar that the item is a child of changes. For custom subclasses of Gtk.ToolItem, the default handler of this signal use the functions

Property Details

Gtk.ToolItem.props.is_important
Name:

is-important

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the toolbar item is considered important. When True, toolbar buttons show text in Gtk.ToolbarStyle.BOTH_HORIZ mode

Gtk.ToolItem.props.visible_horizontal
Name:

visible-horizontal

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the toolbar item is visible when the toolbar is in a horizontal orientation.

Gtk.ToolItem.props.visible_vertical
Name:

visible-vertical

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the toolbar item is visible when the toolbar is in a vertical orientation.