Description
A gtk.Toolbar is a
subclass of gtk.Container
that holds and manages a set of buttons and widgets in a horizontal or
vertical bar. A gtk.Toolbar is
usually used in an application as an alternative to a menu to provide a more
direct means to activate dialogs or set options. Items in the toolbar can be
visibly grouped by adding space between the elements. The toolbar style can
be set to display only icons, only text or both icons and text. Each toolbar
item has an associated gtk.Tooltips to
provide a brief description of the items purpose.
In PyGTK 2.4 the interface of the gtk.Toolbar has
changed to take advantage of the new gtk.ToolItem
widgets. The following describes the new features.
A toolbar can contain instances of a subclass of gtk.ToolItem
(gtk.ToolButton,
gtk.RadioToolButton,
gtk.ToggleToolButton
and gtk.SeparatorToolItem). To
add a gtk.ToolItem to
the a toolbar, use the insert()
method. To remove an item from the toolbar use the gtk.Container.remove()
method. To add a button to the toolbar, add an instance of gtk.ToolButton. Toolbar
items can be visually grouped by adding instances of gtk.SeparatorToolItem
to the toolbar. If a gtk.SeparatorToolItem
has the "expand" property set to TRUE and the "draw"
property set to FALSE the effect is to force all
following items to the end of the toolbar. Creating a context menu for the
toolbar can be done by connecting to the "popup-context-menu" signal.
Methods
gtk.Toolbar.insert
Note
This method is available in PyGTK 2.4 and above
The insert() method inserts the gtk.ToolItem
specified by item into the toolbar at the position
specified by pos. If pos is 0
item is prepended to the start of the toolbar. If
pos is negative, item is
appended to the end of the toolbar.
gtk.Toolbar.get_item_index
item : | a gtk.ToolItem
that is a child of the toolbar |
Returns : | the position of item on the
toolbar. |
Note
This method is available in PyGTK 2.4 and above
The get_item_index() method returns the
position (starting from 0) on the toolbar of the gtk.ToolItem
specified by item. It is an error
if item is not a child of the toolbar.
gtk.Toolbar.get_n_items
Returns : | the number of items on the
toolbar |
Note
This method is available in PyGTK 2.4 and above
The get_n_items() method returns the
number of items on the toolbar.
gtk.Toolbar.get_nth_item
n : | a position on the toolbar |
Returns : | The gtk.ToolItem
on the toolbar at position n, or
None if there isn't an item at position
n |
Note
This method is available in PyGTK 2.4 and above
The get_nth_item() method returns the
toolbar gtk.ToolItem at
the position specified by n, or
None if the toolbar does not contain an item at position
n.
gtk.Toolbar.get_drop_index
x : | the x coordinate of a point on the
toolbar |
y : | the y coordinate of a point on the
toolbar |
Returns : | The toolbar position corresponding to the point
(x,
y). |
Note
This method is available in PyGTK 2.4 and above
The get_drop_index() method returns the
position on the toolbar corresponding to the point specified by
x and y. This is useful when
dragging items to the toolbar. This method returns the position index where
a new item should be inserted.
The x and y
coordinates are relative to the toolbar.
gtk.Toolbar.set_drop_highlight_item
def set_drop_highlight_item(tool_item, index)
|
tool_item : | a gtk.ToolItem,
or None to turn off
highlighting |
index : | a position index on the toolbar |
Note
This method is available in PyGTK 2.4 and above
The set_drop_highlight_item() method
highlights the toolbar to give an idea of what it would look like if the
gtk.ToolItem
specified by tool_item was added at the position
specified by index. If
tool_item is None, highlighting is
turned off and index is ignored.
The tool_item passed to this method must
not be part of any widget hierarchy. When an item is set as drop highlight
item it can not added to any widget hierarchy or used as highlight item for
another toolbar.
gtk.Toolbar.set_show_arrow
def set_show_arrow(show_arrow)
|
show_arrow : | if TRUE, show an arrow to
indicate menu overflow |
Note
This method is available in PyGTK 2.4 and above
The set_show_arrow() method sets the
"show-arrow" property to the value of show_arrow. If
show_arrow is TRUE an arrow is
displayed (for an overflow menu) when the toolbar doesn't have room for all
items on it. Items that are not displayed due to a lack of room are
available through the overflow menu.
gtk.Toolbar.get_show_arrow
Returns : | TRUE if an overflow menu can
be used |
Note
This method is available in PyGTK 2.4 and above
The get_show_arrow() method returns the
value of the "show-arrow" property. If "show-arrow" is
TRUE the toolbar has an overflow menu. See the set_show_arrow()
method for more information.
gtk.Toolbar.get_relief_style
Returns : | the relief style of buttons on the
toolbar |
Note
This method is available in PyGTK 2.4 and above
The get_relief_style() method returns
the relief style of buttons on the toolbar. See the gtk.Button.set_relief()
method for more information. The return value will be one of:
- gtk.RELIEF_NORMAL
- gtk.RELIEF_HALF
- gtk.RELIEF_NONE
gtk.Toolbar.append_item
def append_item(text, tooltip_text, tooltip_private_text, icon, callback, user_data=None)
|
text : | the text label or
None |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
icon : | a gtk.Widget or
None |
callback : | a callback function or method or
None |
user_data : | a user data object or
None |
Returns : | a gtk.Button
widget |
Warning
This method is deprecated in PyGTK 2.4 and above
The append_item() method adds a new
gtk.Button to
the end (right or bottom) of the toolbar with:
- the label specified by
text,
- the gtk.Tooltips text
and private text specified by tooltip_text and
tooltip_private_text respectively and
- an icon (or any gtk.Widget)
specified by icon.
A reference to the new button is returned. When the button is
clicked the function or method specified by callback
will be called with the user data specified by
user_data. All or any of the arguments can have the
value None.
gtk.Toolbar.prepend_item
def prepend_item(text, tooltip_text, tooltip_private_text, icon, callback, user_data)
|
text : | the text label or
None |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
icon : | a gtk.Widget or
None |
callback : | a callback function or method or
None |
user_data : | a user data object or
None |
Returns : | a gtk.Button
widget |
Warning
This method is deprecated in PyGTK 2.4 and above
The prepend_item() method adds a new
gtk.Button to
the beginning (left or top) of the toolbar with:
- the label specified by
text,
- the gtk.Tooltips text
and private text specified by tooltip_text and
tooltip_private_text respectively and
- an icon (or any gtk.Widget)
specified by icon.
A reference to the new button is returned. When the button is
clicked the function or method specified by callback
will be called with the user data specified by
user_data. All or any of the arguments can have the
value None.
gtk.Toolbar.insert_item
def insert_item(text, tooltip_text, tooltip_private_text, icon, callback, user_data, position)
|
text : | the text label or
None |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
icon : | a gtk.Widget or
None |
callback : | a callback function or method or
None |
user_data : | a user data object or
None |
position : | The position to insert the button or -1 to
append |
Returns : | a gtk.Button
widget |
Warning
This method is deprecated in PyGTK 2.4 and above
The insert_item() method inserts a new
gtk.Button the
toolbar at the position specified by position
with:
- the label specified by
text,
- the gtk.Tooltips text
and private text specified by tooltip_text and
tooltip_private_text respectively and
- an icon (or any gtk.Widget)
specified by icon.
A reference to the new button is returned. When the button is
clicked the function or method specified by callback
will be called with the user data specified by
user_data. All or any of the arguments (except
position) can have the value
None. If position is negative
the button will be appended to the toolbar.
gtk.Toolbar.insert_stock
def insert_stock(stock_id, tooltip_text, tooltip_private_text, callback, user_data, position)
|
stock_id : | the ID of the stock item to use as the button
label and icon |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
callback : | a callback function or method or
None |
user_data : | a user data object or
None |
position : | The position to insert the button or -1 to
append |
Returns : | a gtk.Button
widget |
Warning
This method is deprecated in PyGTK 2.4 and above
The insert_stock() method inserts a new
gtk.Button the
toolbar at the position specified by position
with:
- the stock item specified by
stock_id used for the label text and icon,
- the gtk.Tooltips text
and private text specified by tooltip_text and
tooltip_private_text respectively.
A reference to the new button is returned. When the button is
clicked the function or method specified by callback
will be called with the user data specified by
user_data. All or any of the arguments (except
position) can have the value
None. If position is negative
the button will be appended to the toolbar. If
stock_id is not a known stock item ID, it's inserted
verbatim, except that underscores are used to mark mnemonic
accelerators.
gtk.Toolbar.append_space
Warning
This method is deprecated in PyGTK 2.4 and above
The append_space() method appends a
space to the end of the toolbar.
gtk.Toolbar.prepend_space
Warning
This method is deprecated in PyGTK 2.4 and above
The prepend_space() method prepends a
space to the beginning of the toolbar.
gtk.Toolbar.insert_space
def insert_space(position)
|
position : | The position to insert the space or -1 to
append |
Warning
This method is deprecated in PyGTK 2.4 and above
The insert_space() method inserts a
space at the specified position in the
toolbar.
gtk.Toolbar.remove_space
def remove_space(position)
|
position : | the index of the space to
remove. |
Warning
This method is deprecated in PyGTK 2.4 and above
The remove_space() method removes a
space from the specified position.
gtk.Toolbar.append_element
def append_element(type, widget, text, tooltip_text, tooltip_private_text, icon, callback, user_data)
|
type : | the type of widget - one
of: gtk.TOOLBAR_CHILD_SPACE,
gtk.TOOLBAR_CHILD_BUTTON,
gtk.TOOLBAR_CHILD_TOGGLEBUTTON,
gtk.TOOLBAR_CHILD_RADIOBUTTON or
gtk.TOOLBAR_CHILD_WIDGET |
widget : | a widget or
None |
text : | the text label or
None |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
icon : | a gtk.Widget or
None |
callback : | a callback function or method or
None |
user_data : | a user data object or
None |
Returns : | the new toolbar element as a gtk.Widget. |
Warning
This method is deprecated in PyGTK 2.4 and above
The append_element() method adds a new
element of the specified type to the end (right or
bottom) of the toolbar with the gtk.Tooltips text
and private text specified by tooltip_text and
tooltip_private_text respectively. The behavior of
the method depends on the type of element being added:
gtk.TOOLBAR_CHILD_WIDGET | The specified widget is the
element added to the toolbar. The text,
icon, callback and
user_data arguments are ignored. |
gtk.TOOLBAR_CHILD_BUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.Button to
add to the toolbar. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. The widget argument must have the value
None. |
gtk.TOOLBAR_CHILD_TOGGLEBUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.ToggleButton
to add to the toolbar. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. The widget argument must have the value
None. |
gtk.TOOLBAR_CHILD_RADIOBUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.RadioButton
to add to the toolbar. The gtk.RadioButton
specified by widget is used to set the group for the
radiobutton. If widget is None a
new radiobutton group is created. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. |
gtk.TOOLBAR_CHILD_SPACE | A space element is added to the toolbar. The
widget argument must have the value
None. The text,
icon, tooltip_text,
tooltip_private_text, callback
and user_data arguments are ignored. |
The text, icon,
callback, user_data,
tooltip_text and
tooltip_private_text arguments may have the value
None.
gtk.Toolbar.prepend_element
def prepend_element(type, widget, text, tooltip_text, tooltip_private_text, icon, callback, user_data)
|
type : | the type of widget - one
of: gtk.TOOLBAR_CHILD_SPACE,
gtk.TOOLBAR_CHILD_BUTTON,
gtk.TOOLBAR_CHILD_TOGGLEBUTTON,
gtk.TOOLBAR_CHILD_RADIOBUTTON or
gtk.TOOLBAR_CHILD_WIDGET |
widget : | a widget or
None |
text : | the text label or
None |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
icon : | a gtk.Widget or
None |
callback : | a callback function or method or
None |
user_data : | a user data object or
None |
Returns : | the new toolbar element as a gtk.Widget. |
Warning
This method is deprecated in PyGTK 2.4 and above
The prepend_element() method adds a new
element of the specified type to the beginning (left
or top) of the toolbar with the gtk.Tooltips text
and private text specified by tooltip_text and
tooltip_private_text respectively. The behavior of
the method depends on the type of element being added:
gtk.TOOLBAR_CHILD_WIDGET | The widget specified by widget
is the element added to the toolbar, otherwise widget
should be None. The text,
icon, callback and
user_data arguments are ignored. |
gtk.TOOLBAR_CHILD_BUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.Button to
add to the toolbar. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. The widget argument must have the value
None. |
gtk.TOOLBAR_CHILD_TOGGLEBUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.ToggleButton
to add to the toolbar. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. The widget argument must have the value
None. |
gtk.TOOLBAR_CHILD_RADIOBUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.RadioButton
to add to the toolbar. The gtk.RadioButton
specified by widget is used to set the group for the
radiobutton. If widget is None a
new radiobutton group is created. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. |
gtk.TOOLBAR_CHILD_SPACE | A space element is added to the toolbar. The
widget argument must have the value
None. The text,
icon, tooltip_text,
tooltip_private_text, callback
and user_data arguments are ignored. |
The text, icon,
callback, user_data,
tooltip_text and
tooltip_private_text arguments may have the value
None.
gtk.Toolbar.insert_element
def insert_element(type, widget, text, tooltip_text, tooltip_private_text, icon, callback, user_data, position)
|
type : | the type of widget - one
of: gtk.TOOLBAR_CHILD_SPACE,
gtk.TOOLBAR_CHILD_BUTTON,
gtk.TOOLBAR_CHILD_TOGGLEBUTTON,
gtk.TOOLBAR_CHILD_RADIOBUTTON or
gtk.TOOLBAR_CHILD_WIDGET |
widget : | a widget or
None |
text : | the text label or
None |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
icon : | a gtk.Widget or
None |
callback : | a callback function or method or
None |
user_data : | a user data object or
None |
position : | the position to insert the new element
at. |
Returns : | the new toolbar element as a gtk.Widget. |
Warning
This method is deprecated in PyGTK 2.4 and above
The insert_element() method adds a new
element of the specified type at the specified
position in the toolbar with the gtk.Tooltips text
and private text specified by tooltip_text and
tooltip_private_text respectively. The behavior of
the method depends on the type of element being added:
gtk.TOOLBAR_CHILD_WIDGET | The widget specified by widget
is the element added to the toolbar, otherwise widget
should be None. The text,
icon, callback and
user_data arguments are ignored. |
gtk.TOOLBAR_CHILD_BUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.Button to
add to the toolbar. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. The widget argument must have the value
None. |
gtk.TOOLBAR_CHILD_TOGGLEBUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.ToggleButton
to add to the toolbar. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. The widget argument must have the value
None. |
gtk.TOOLBAR_CHILD_RADIOBUTTON | The string specified by text and
the gtk.Widget
specified by icon are used to create the label for a
gtk.RadioButton
to add to the toolbar. The gtk.RadioButton
specified by widget is used to set the group for the
radiobutton. If widget is None a
new radiobutton group is created. The function or method specified by
callback and the object specified by
user_data are connected to the button's "clicked"
signal. |
gtk.TOOLBAR_CHILD_SPACE | A space element is added to the toolbar. The
widget argument must have the value
None. The text,
icon, tooltip_text,
tooltip_private_text, callback
and user_data arguments are ignored. |
The text, icon,
callback, user_data,
tooltip_text and
tooltip_private_text arguments may have the value
None.
gtk.Toolbar.append_widget
def append_widget(widget, tooltip_text, tooltip_private_text)
|
widget : | a gtk.Widget to add to
the toolbar. |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
Warning
This method is deprecated in PyGTK 2.4 and above
The append_widget() method adds the
specified widget to the end (right or bottom) of the
toolbar. tooltip_text and
tooltip_private_text specify the tooltip text and
private text respectively.
gtk.Toolbar.prepend_widget
def prepend_widget(widget, tooltip_text, tooltip_private_text)
|
widget : | a gtk.Widget to add to
the toolbar. |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
Warning
This method is deprecated in PyGTK 2.4 and above
The prepend_widget() method adds the
specified widget to the start (left or top) of the
toolbar. tooltip_text and
tooltip_private_text specify the tooltip text and
private text respectively.
gtk.Toolbar.insert_widget
def insert_widget(widget, tooltip_text, tooltip_private_text, position)
|
widget : | a gtk.Widget to add to
the toolbar. |
tooltip_text : | the tooltip text or
None |
tooltip_private_text : | the private tooltip text or
None |
position : | the position to insert this widget
at. |
Warning
This method is deprecated in PyGTK 2.4 and above
The insert_widget() method adds the
specified widget at the specified
position in the toolbar.
tooltip_text and
tooltip_private_text specify the tooltip text and
private text respectively.
gtk.Toolbar.set_orientation
def set_orientation(orientation)
|
orientation : | the new orientation either
gtk.ORIENTATION_HORIZONTAL or
gtk.ORIENTATION_VERTICAL |
The set_orientation() method sets the
"orientation" property to the value of orientation.
The value of orientation is either
gtk.ORIENTATION_HORIZONTAL or
gtk.ORIENTATION_VERTICAL
gtk.Toolbar.set_style
style : | the new style - one of:
gtk.TOOLBAR_ICONS, gtk.TOOLBAR_TEXT,
gtk.TOOLBAR_BOTH or
gtk.TOOLBAR_BOTH_HORIZ |
The set_style() method sets the
"toolbar-style" property to the value of style. The
value of style must be one of the GTK Toolbar Style Constants. Setting the style
overrides the user preferences for the toolbar style.
gtk.Toolbar.set_icon_size
def set_icon_size(icon_size)
|
icon_size : | The size of stock icons in the toolbar - one
of: gtk.ICON_SIZE_MENU,
gtk.ICON_SIZE_SMALL_TOOLBAR,
gtk.ICON_SIZE_LARGE_TOOLBAR,
gtk.ICON_SIZE_BUTTON,
gtk.ICON_SIZE_DND or
gtk.ICON_SIZE_DIALOG |
Warning
This method is deprecated in PyGTK 2.4 and above
The set_icon_size() method sets the
size of stock icons in the toolbar to the value specified by
icon_size. The value of
icon_size must be one of:
- gtk.ICON_SIZE_MENU
- gtk.ICON_SIZE_SMALL_TOOLBAR
- gtk.ICON_SIZE_LARGE_TOOLBAR
- gtk.ICON_SIZE_BUTTON
- gtk.ICON_SIZE_DND, or
- gtk.ICON_SIZE_DIALOG
This method can be called both before and after adding the
icons. Setting the icon size will override the user preferences for the
default icon size.
gtk.Toolbar.set_tooltips
enable : | if TRUE tooltips should be
used |
The set_tooltips() method enables or
disables tooltips for the toolbar depending on the value of
enable. If enable is
TRUE, tooltips will be used.
gtk.Toolbar.unset_style
The unset_style() method unsets a
toolbar style set with the set_style()
method, allowing the user preferences to determine the toolbar style.
gtk.Toolbar.unset_icon_size
Warning
This method is deprecated in PyGTK 2.4 and above
The unset_icon_size() method unsets
toolbar icon size set with the set_icon_size(),
allowing the user preferences to determine the icon size.
gtk.Toolbar.get_orientation
The get_orientation() method returns
the value of the "orientation" property that determines the current
orientation of the toolbar. See the set_orientation()
method for more details.
gtk.Toolbar.get_style
Returns : | the current toolbar style |
The get_style() method returns the
value of the "toolbar-style" property. See the set_style()
method for more details.
gtk.Toolbar.get_icon_size
Returns : | the current icon size for the icons on the
toolbar. |
The get_icon_size() method returns the
current icon size for the toolbar. See the set_icon_size()
method for more details.
gtk.Toolbar.get_tooltips
Returns : | TRUE if tooltips are
enabled |
The get_tooltips() method returns
TRUE if tooltips are enabled. See the set_tooltips()
method for more details.