sugar4.graphics.toolbutton
The toolbutton module provides the ToolButton class, which is a Gtk.Button styled as a toolbar button with icon and tooltip for sugar4.
Example
Add a tool button to a window:
from gi.repository import Gtk
from sugar4.graphics.toolbutton import ToolButton
def __clicked_cb(button):
print("tool button was clicked")
app = Gtk.Application()
def on_activate(app):
w = Gtk.ApplicationWindow(application=app)
b = ToolButton(icon_name='dialog-ok', tooltip='a tooltip')
b.connect('clicked', __clicked_cb)
w.set_child(b)
w.present()
app.connect('activate', on_activate)
app.run()
STABLE.
Attributes
Classes
The ToolButton class manages a Gtk.Button styled as a toolbar button for sugar4. |
Functions
|
Module Contents
- class sugar4.graphics.toolbutton.ToolButton(icon_name=None, **kwargs)[source]
Bases:
gi.repository.Gtk.ButtonThe ToolButton class manages a Gtk.Button styled as a toolbar button for sugar4.
This replaces deprecated ToolButton with a modern Button implementation styled to look and behave like a traditional toolbar button.
- Parameters:
- set_tooltip(tooltip: str | None)[source]
Set the tooltip.
- Parameters:
tooltip (string) – tooltip to be set.
- get_hide_tooltip_on_click() → bool[source]
Return True if the tooltip is hidden when a user clicks on the button, otherwise return False.
- set_hide_tooltip_on_click(hide_tooltip_on_click: bool)[source]
Set whether or not the tooltip is hidden when a user clicks on the button.
- Parameters:
hide_tooltip_on_click (bool) – True if the tooltip is
click (hidden on)
otherwise. (and False)
- set_accelerator(accelerator: str | None)[source]
Set accelerator that activates the button.
- Parameters:
accelerator (string) – accelerator to be set.
- get_icon_name() → str | None[source]
Get the icon name.
- Returns:
The icon name or None if no icon is set.
- set_icon_widget(icon_widget: gi.repository.Gtk.Widget | None)[source]
Set a custom icon widget.
- Parameters:
icon_widget – widget to use as icon.
- create_palette() → sugar4.graphics.palette.Palette | None[source]
- get_palette() → sugar4.graphics.palette.Palette | None[source]
Get the current palette.
- set_palette(palette: sugar4.graphics.palette.Palette | None)[source]