sugar3.graphics.toolbutton module

The toolbutton module provides the ToolButton class, which is a Gtk.ToolButton with icon and tooltip styled for Sugar.

Example

Add a tool button to a window

from gi.repository import Gtk from sugar3.graphics.toolbutton import ToolButton

def __clicked_cb(button):

print(“tool button was clicked”)

w = Gtk.Window() w.connect(‘destroy’, Gtk.main_quit) b = ToolButton(icon_name=’dialog-ok’, tooltip=’a tooltip’) b.connect(‘clicked’, __clicked_cb) w.add(b) w.show_all()

Gtk.main()

STABLE.

class sugar3.graphics.toolbutton.ToolButton(icon_name=None, **kwargs)

Bases: gi.overrides.Gtk.ToolButton

The ToolButton class manages a Gtk.ToolButton styled for Sugar.

Keyword Arguments
  • icon_name (string) – name of themed icon.

  • accelerator (string) – keyboard shortcut to be used to activate this button.

  • tooltip (string) – tooltip to be displayed when user hovers over button.

  • hide_tooltip_on_click (bool) – Whether or not the tooltip is hidden when user clicks on button.

accelerator

Return accelerator that activates the button.

create_palette()
do_clicked()

Implementation method for hiding the tooltip when the button is clicked.

do_draw(cr)

Implementation method for drawing the button.

do_get_property(pspec)
do_set_property(pspec, value)
get_accelerator()

Return accelerator that activates the button.

get_hide_tooltip_on_click()

Return True if the tooltip is hidden when a user clicks on the button, otherwise return False.

get_icon_name()

Return icon name, or None if there is no icon name.

get_palette()
get_palette_invoker()
get_tooltip()

Return the tooltip.

hide_tooltip_on_click

Return True if the tooltip is hidden when a user clicks on the button, otherwise return False.

icon_name

Return icon name, or None if there is no icon name.

palette
palette_invoker
set_accelerator(accelerator)

Set accelerator that activates the button.

Parameters

accelerator (string) – accelerator to be set.

set_hide_tooltip_on_click(hide_tooltip_on_click)

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

  • otherwise. (hidden on click, and False) –

set_icon_name(icon_name)

Set name of icon.

Parameters

icon_name (string) – name of icon

set_palette(palette)
set_palette_invoker(palette_invoker)
set_tooltip(tooltip)

Set the tooltip.

Parameters

tooltip (string) – tooltip to be set.

tooltip

Return the tooltip.

sugar3.graphics.toolbutton.setup_accelerator(tool_button)