gtk.Toolbar — a bar holding buttons and other widgets.
class gtk.Toolbar(gtk.Container): |
|
|
|
gtk.Container Signal Prototypes
def callback( | |
def callback( | |
def callback( | |
def callback( | |
def callback( |
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.
def insert(item
, pos
)
| a gtk.ToolItem |
| the position of the new item |
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.
def get_item_index(item
)
| a gtk.ToolItem
that is a child of the toolbar |
Returns : | the position of item on the toolbar. |
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.
def get_n_items()
Returns : | the number of items on the toolbar |
This method is available in PyGTK 2.4 and above
The get_n_items
() method returns the
number of items on the toolbar.
def 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 |
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
.
def get_drop_index(x
, y
)
| the x coordinate of a point on the toolbar |
| the y coordinate of a point on the toolbar |
Returns : | The toolbar position corresponding to the point
(x ,
y ). |
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.
def set_drop_highlight_item(tool_item
, index
)
| a gtk.ToolItem ,
or None to turn off
highlighting |
| a position index on the toolbar |
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.
def set_show_arrow(show_arrow
)
| if True , show an arrow to
indicate menu overflow |
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.
def get_show_arrow()
Returns : | True if an overflow menu can
be used |
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.
def get_relief_style()
Returns : | the relief style of buttons on the toolbar |
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
def append_item(text
, tooltip_text
, tooltip_private_text
, icon
, callback
, user_data
=None)
| the text label or
None |
| the tooltip text or
None |
| the private tooltip text or
None |
| a gtk.Widget or
None |
| a callback function or method or
None |
| a user data object or
None |
Returns : | a gtk.Button
widget |
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:
text
,gtk.Tooltips
text
and private text specified by tooltip_text
and
tooltip_private_text
respectively andgtk.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
.
def prepend_item(text
, tooltip_text
, tooltip_private_text
, icon
, callback
, user_data
)
| the text label or
None |
| the tooltip text or
None |
| the private tooltip text or
None |
| a gtk.Widget or
None |
| a callback function or method or
None |
| a user data object or
None |
Returns : | a gtk.Button
widget |
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:
text
,gtk.Tooltips
text
and private text specified by tooltip_text
and
tooltip_private_text
respectively andgtk.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
.
def insert_item(text
, tooltip_text
, tooltip_private_text
, icon
, callback
, user_data
, position
)
| the text label or
None |
| the tooltip text or
None |
| the private tooltip text or
None |
| a gtk.Widget or
None |
| a callback function or method or
None |
| a user data object or
None |
| The position to insert the button or -1 to append |
Returns : | a gtk.Button
widget |
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:
text
,gtk.Tooltips
text
and private text specified by tooltip_text
and
tooltip_private_text
respectively andgtk.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.
def insert_stock(stock_id
, tooltip_text
, tooltip_private_text
, callback
, user_data
, position
)
| the ID of the stock item to use as the button label and icon |
| the tooltip text or
None |
| the private tooltip text or
None |
| a callback function or method or
None |
| a user data object or
None |
| The position to insert the button or -1 to append |
Returns : | a gtk.Button
widget |
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:
stock_id
used for the label text and icon,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.
def append_space()
This method is deprecated in PyGTK 2.4 and above
The append_space
() method appends a
space to the end of the toolbar.
def prepend_space()
This method is deprecated in PyGTK 2.4 and above
The prepend_space
() method prepends a
space to the beginning of the toolbar.
def insert_space(position
)
| The position to insert the space or -1 to append |
This method is deprecated in PyGTK 2.4 and above
The insert_space
() method inserts a
space at the specified position
in the
toolbar.
def remove_space(position
)
| the index of the space to remove. |
This method is deprecated in PyGTK 2.4 and above
The remove_space
() method removes a
space from the specified position
.
def append_element(type
, widget
, text
, tooltip_text
, tooltip_private_text
, icon
, callback
, user_data
)
| 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 |
| a widget or
None |
| the text label or
None |
| the tooltip text or
None |
| the private tooltip text or
None |
| a gtk.Widget or
None |
| a callback function or method or
None |
| a user data object or
None |
Returns : | the new toolbar element as a gtk.Widget . |
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:
| The specified widget is the
element added to the toolbar. The text ,
icon , callback and
user_data arguments are ignored. |
| 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 . |
| 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 . |
| 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. |
| 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
.
def prepend_element(type
, widget
, text
, tooltip_text
, tooltip_private_text
, icon
, callback
, user_data
)
| 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 |
| a widget or
None |
| the text label or
None |
| the tooltip text or
None |
| the private tooltip text or
None |
| a gtk.Widget or
None |
| a callback function or method or
None |
| a user data object or
None |
Returns : | the new toolbar element as a gtk.Widget . |
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:
| 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. |
| 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 . |
| 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 . |
| 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. |
| 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
.
def insert_element(type
, widget
, text
, tooltip_text
, tooltip_private_text
, icon
, callback
, user_data
, position
)
| 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 |
| a widget or
None |
| the text label or
None |
| the tooltip text or
None |
| the private tooltip text or
None |
| a gtk.Widget or
None |
| a callback function or method or
None |
| a user data object or
None |
| the position to insert the new element at. |
Returns : | the new toolbar element as a gtk.Widget . |
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:
| 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. |
| 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 . |
| 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 . |
| 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. |
| 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
.
def append_widget(widget
, tooltip_text
, tooltip_private_text
)
| a gtk.Widget to add to
the toolbar. |
| the tooltip text or
None |
| the private tooltip text or
None |
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.
def prepend_widget(widget
, tooltip_text
, tooltip_private_text
)
| a gtk.Widget to add to
the toolbar. |
| the tooltip text or
None |
| the private tooltip text or
None |
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.
def insert_widget(widget
, tooltip_text
, tooltip_private_text
, position
)
| a gtk.Widget to add to
the toolbar. |
| the tooltip text or
None |
| the private tooltip text or
None |
| the position to insert this widget at. |
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.
def set_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
def 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.
A gtk.ToolItem
label
will not be displayed if the toolbar style is
gtk.TOOLBAR_BOTH_HORIZ
and the gtk.ToolItem
"is-important" property is False
(the default). See the
gtk.ToolItem.set_is_important
()
method for more information.
def set_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 |
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
, orgtk.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.
def 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.
def 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.
def unset_icon_size()
The unset_icon_size
() method unsets
toolbar icon size set with the set_icon_size
(),
allowing the user preferences to determine the icon size.
def get_orientation()
Returns : | the 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.
def 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.
def 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.
def 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.
def callback(toolbar
, focus_home
, user_param1
, ...
)
| the gtk.Toolbar which emitted the signal
the object which received the signal. |
| True if the first item
should be focused |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
Returns : | True if the signal was
handled, False if not |
A keybinding signal used internally by GTK+. This signal can't be used in application code
def callback(toolbar
, dir
, arg1
, user_param1
, ...
)
| the gtk.Toolbar
which emitted the signal the object which received the
signal. |
| one of the GTK Direction Type Constants |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
Returns : | True if the signal was
handled, False if not |
A keybinding signal used internally by GTK+. This signal can't be used in application code.
def callback(toolbar
, orientation
, user_param1
, ...
)
| the toolbar that received the signal |
| the new orientation |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
The "orientation-changed" signal is emitted when the
orientation
of toolbar
is
changed.
def callback(toolbar
, x
, y
, button
, user_param1
, ...
)
| the toolbar that received the signal |
| the x coordinate of the mouse event |
| the u coordinate of the mouse event |
| the number of the mouse button |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
Returns : | True if the signal was
handled |
This signal is available in GTK+ 2.4 and above.
The "popup-context-menu" signal is emitted when the user
right-clicks the toolbar or uses the keybinding to display a popup
menu. Application developers should handle this signal if they want to
display a context menu on the toolbar. The context-menu should appear at the
coordinates given by x
and
y
. The mouse button number is given by the
button
parameter. If the menu was popped up using the
keyboard, button
is -1.
def callback(toolbar
, style
, user_param1
, ...
)
| the toolbar that received the signal |
| the new style |
| the first user parameter (if any) specified
with the connect () |
| additional user parameters (if any) |
The "style-changed" signal is emitted when the
style
of toolbar
is
changed.