Gtk.ToolButton
Gtk.ToolButton — A Gtk.ToolItem subclass that displays buttons
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Container
╰── Gtk.Bin
╰── Gtk.ToolItem
╰── Gtk.ToolButton
├── Gtk.MenuToolButton
╰── Gtk.ToggleToolButton
See also:
Gtk.Toolbar Gtk.MenuToolButton Gtk.ToggleToolButton
Functions:
- new
(icon_widget:Gtk.Widget=None, label:str=None) -> Gtk.ToolItem
- new_from_stock
(stock_id:str) -> Gtk.ToolItem
- set_label
(self, label:str=None)
- get_label
(self) -> str
- set_use_underline
(self, use_underline:bool)
- get_use_underline
(self) -> bool
- set_stock_id
(self, stock_id:str=None)
- get_stock_id
(self) -> str
- set_icon_name
(self, icon_name:str=None)
- get_icon_name
(self) -> str
- set_icon_widget
(self, icon_widget:Gtk.Widget=None)
- get_icon_widget
(self) -> Gtk.Widget
- set_label_widget
(self, label_widget:Gtk.Widget=None)
- get_label_widget
(self) -> Gtk.Widget
Description:
GtkRadioToolButton, Gtk.SeparatorToolItem Gtk.ToolButton
s are GtkToolItems containing buttons.
Use Gtk.ToolButton::new()
to create a new Gtk.ToolButton
.
The label of a Gtk.ToolButton
is determined by the properties non-None, then that widget is used as the label. Otherwise, if Gtk.ToolButton::stock-id
is non-None, the label is determined by the stock item. Otherwise, the button does not have a label.
The icon of a Gtk.ToolButton
is determined by the properties that widget is used as the icon. Otherwise, if Gtk.ToolButton::stock-id
is non-None, the icon is determined by the stock item. Otherwise, the button does not have a icon.
Function Details:
new()
new (icon_widget:Gtk.Widget=None, label:str=None) -> Gtk.ToolItem
Creates a new Gtk.ToolButton
using icon_widget
as contents and label
aslabel.
Returns: A new Gtk.ToolButton
Since: 2.4
new_from_stock()
new_from_stock (stock_id:str) -> Gtk.ToolItem
Gtk.ToolButton:new_from_stock
has been deprecated since version 3.10 and should not be used in newly-written code.
Use Gtk.ToolButton:new()
together with`Gtk.Image:new_from_icon_name
()instead.
Creates a new
Gtk.ToolButtoncontaining the image and text from astock item. Some stock ids have preprocessor macros like GTK_STOCK_OKand GTK_STOCK_APPLY.
It is an error if
stock_id` is not a name of a stock item.
Returns: A new Gtk.ToolButton
Since: 2.4
set_label()
set_label (self, label:str=None)
Sets label
as the label used for the tool button. The “label”property only has an effect if not overridden by a non-None
“label-widget” property. If both the “label-widget”and “label” properties are None
, the label is determined by the“stock-id” property. If the “stock-id” property isalso None
, button
will not have a label.
- Since: 2.4
get_label()
get_label (self) -> str
Returns the label used by the tool button, or None
if the tool buttondoesn’t have a label. or uses a the label from a stock item. The returnedstring is owned by GTK+, and must not be modified or freed.
Returns: The label, or
None
Since: 2.4
set_use_underline()
set_use_underline (self, use_underline:bool)
If set, an underline in the label property indicates that the next charactershould be used for the mnemonic accelerator key in the overflow menu. Forexample, if the label property is “_Open” and use_underline
is True
,the label on the tool button will be “Open” and the item on the overflowmenu will have an underlined “O”.
Labels shown on tool buttons never have mnemonics on them; this propertyonly affects the menu item on the overflow menu.
- Since: 2.4
get_use_underline()
get_use_underline (self) -> bool
Returns whether underscores in the label property are used as mnemonicson menu items on the overflow menu. See Gtk.ToolButton:set_use_underline()
.
Returns:
True
if underscores in the label property are used asmnemonics on menu items on the overflow menu.Since: 2.4
set_stock_id()
set_stock_id (self, stock_id:str=None)
Gtk.ToolButton:set_stock_id
has been deprecated since version 3.10 and should not be used in newly-written code.
Use Gtk.ToolButton:set_icon_name()
instead.
Sets the name of the stock item. See Gtk.ToolButton:new_from_stock()
.The stock_id property only has an effect if not overridden by non-None
“label-widget” and “icon-widget” properties.
- Since: 2.4
get_stock_id()
get_stock_id (self) -> str
Gtk.ToolButton:get_stock_id
has been deprecated since version 3.10 and should not be used in newly-written code.
Use Gtk.ToolButton:get_icon_name()
instead.
Returns the name of the stock item. See Gtk.ToolButton:set_stock_id()
.The returned string is owned by GTK+ and must not be freed or modifed.
Returns: the name of the stock item for
button
.Since: 2.4
set_icon_name()
set_icon_name (self, icon_name:str=None)
Sets the icon for the tool button from a named themed icon.See the docs for Gtk.IconTheme
for more details.The “icon-name” property only has an effect if notoverridden by non-None
“label-widget”, “icon-widget” and “stock-id” properties.
- Since: 2.8
get_icon_name()
get_icon_name (self) -> str
Returns the name of the themed icon for the tool button,see Gtk.ToolButton:set_icon_name()
.
Returns: the icon name or
None
if the tool button hasno themed iconSince: 2.8
set_icon_widget()
set_icon_widget (self, icon_widget:Gtk.Widget=None)
Sets icon
as the widget used as icon on button
. If icon_widget
isNone
the icon is determined by the “stock-id” property. If the“stock-id” property is also None
, button
will not have an icon.
- Since: 2.4
get_icon_widget()
get_icon_widget (self) -> Gtk.Widget
Return the widget used as icon widget on button
.See Gtk.ToolButton:set_icon_widget()
.
Returns: The widget used as iconon
button
, orNone
.Since: 2.4
set_label_widget()
set_label_widget (self, label_widget:Gtk.Widget=None)
Sets label_widget
as the widget that will be used as the labelfor button
. If label_widget
is None
the “label” property is usedas label. If “label” is also None
, the label in the stock itemdetermined by the “stock-id” property is used as label. If“stock-id” is also None
, button
does not have a label.
- Since: 2.4
get_label_widget()
get_label_widget (self) -> Gtk.Widget
Returns the widget used as label on button
.See Gtk.ToolButton:set_label_widget()
.
Returns: The widget used as labelon
button
, orNone
.Since: 2.4