PyGTK Toolbar Class - PyGTK

What is PyGTK Toolbar Class?

Toolbar class is inherited from the gtk.Container class. It grips and achieves a set of buttons and other widgets. One or more horizontal strips of buttons are usually seen just below the menu bar in a top level window. The Toolbar can also be put in a removable window called HandleBox. By default, the buttons in the gtk.Toolbar widget are laid horizontally. Vertical toolbar can be set up by setting the orientation property to gtk.ORIENTATION_VERTICAL.

The toolbar can be configured to show buttons with icons, text, or both. The style enumerators are −


These buttons display only icons in the toolbar.


These buttons display only text labels in the toolbar.


These buttons display text and icons in the toolbar.


These buttons display icons and text alongside each other, rather than vertically stacked.

A Toolbar widget is set up using the following constructor –

The constituents of Toolbar are examples of the gtk.ToolItem. The items can be ToolButton, RadioToolButton, ToggleToolButton, or SeparatorToolItem. In order to allocate icon to the ToolItem object, images with predefined stock_ID can be used or a custom image can be assigned by the set_image() method.
The resulting instances show how to construct different ToolItems −



Note that multiple radio buttons are put in the same group.


These items are put in the toolbar by calling its insert method.

For instance,

You can also allocate a tooltip to the ToolButton using the set_tooltip_text() nethod. For example, New tooltip is assigned to the new ToolButton.


The resulting code displays a toplevel window with a tool bar set up to contain normal tool item, radio items and a separator item.

The above code will make the resulting output –


All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

PyGTK Topics