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 −

gtk.TOOLBAR_ICONS

These buttons display only icons in the toolbar.

gtk.TOOLBAR_TEXT

These buttons display only text labels in the toolbar.

gtk.TOOLBAR_BOTH

These buttons display text and icons in the toolbar.

gtk.TOOLBAR_BOTH_HORIZ

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 −

ToolButton

RadioToolButton


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

SeparatorToolItem

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.

Example

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 –

toolbar_demo

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PyGTK Topics