sugar4.graphics.menuitem

Sugar-style menu items with icon and accelerator support. This implementation replaces deprecated ImageMenuItem with modern equivalents.

Classes

MenuItem

A Sugar-style menu item with icon and text support.

MenuSeparator

A separator for use in menus.

Module Contents

class sugar4.graphics.menuitem.MenuItem(text_label: str | None = None, icon_name: str | None = None, text_maxlen: int = style.MENU_WIDTH_CHARS, xo_color=None, file_name: str | None = None)[source]

Bases: gi.repository.Gtk.Button

A Sugar-style menu item with icon and text support.

This replaces the deprecated ImageMenuItem with a Button that can be used in menus and popover menus.

Parameters:
  • text_label (str) – Text to display on the menu item

  • icon_name (str) – Name of icon to display

  • text_maxlen (int) – Maximum text length before ellipsizing

  • xo_color – XO color scheme for the icon

  • file_name (str) – Path to icon file

__gtype_name__ = 'SugarMenuItem'[source]
set_accelerator(accelerator: str | None)[source]

Set keyboard accelerator for this menu item.

Parameters:

accelerator (str) – Accelerator string (e.g., ‘<Ctrl>s’)

get_accelerator() str | None[source]

Get the current accelerator string.

Returns:

Current accelerator or None

Return type:

str

set_text(text: str)[source]

Set the text label of the menu item.

Parameters:

text (str) – New text to display

get_text() str[source]

Get the current text of the menu item.

Returns:

Current text or empty string

Return type:

str

accelerator[source]
class sugar4.graphics.menuitem.MenuSeparator[source]

Bases: gi.repository.Gtk.Separator

A separator for use in menus.

Simple wrapper around Gtk.Separator with menu-appropriate styling.