sugar package
Subpackages
- sugar.activity package
- Submodules
- sugar.activity.activity module
- Activity
PREVIEW_SIZE
Activity
Activity.__init__()
Activity.add_stop_button()
Activity.iconify()
Activity.run_main_loop()
Activity.get_active()
Activity.set_active()
Activity.active
Activity.get_max_participants()
Activity.set_max_participants()
Activity.get_id()
Activity.get_bundle_id()
Activity.get_canvas()
Activity.set_canvas()
Activity.canvas
Activity.get_activity_root()
Activity.read_file()
Activity.write_file()
Activity.notify_user()
Activity.get_preview()
Activity.save()
Activity.copy()
Activity.get_shared_activity()
Activity.get_shared()
Activity.invite()
Activity.share()
Activity.can_close()
Activity.close()
Activity.get_metadata()
Activity.metadata
Activity.handle_view_source()
Activity.get_document_path()
Activity.busy()
Activity.unbusy()
SimpleActivity
get_bundle_name()
get_bundle_path()
get_activity_root()
show_object_in_journal()
launch_bundle()
get_bundle()
- sugar.activity.activityhandle module
- sugar.activity.widgets module
- Module contents
- Activity Module
Activity
Activity.__init__()
Activity.add_stop_button()
Activity.busy()
Activity.can_close()
Activity.canvas
Activity.close()
Activity.copy()
Activity.get_active()
Activity.get_activity_root()
Activity.get_bundle_id()
Activity.get_canvas()
Activity.get_document_path()
Activity.get_id()
Activity.get_max_participants()
Activity.get_metadata()
Activity.get_preview()
Activity.get_shared()
Activity.get_shared_activity()
Activity.handle_view_source()
Activity.iconify()
Activity.invite()
Activity.metadata
Activity.notify_user()
Activity.read_file()
Activity.run_main_loop()
Activity.save()
Activity.set_active()
Activity.set_canvas()
Activity.set_max_participants()
Activity.share()
Activity.unbusy()
Activity.write_file()
SimpleActivity
- sugar.bundle package
- Submodules
- sugar.bundle.activitybundle module
ActivityBundle
ActivityBundle.MIME_TYPE
ActivityBundle.__init__()
ActivityBundle.get_locale_path()
ActivityBundle.get_icons_path()
ActivityBundle.get_name()
ActivityBundle.get_bundle_id()
ActivityBundle.get_icon()
ActivityBundle.get_icon_filename()
ActivityBundle.get_activity_version()
ActivityBundle.get_command()
ActivityBundle.get_mime_types()
ActivityBundle.get_tags()
ActivityBundle.get_summary()
ActivityBundle.get_description()
ActivityBundle.get_single_instance()
ActivityBundle.get_max_participants()
ActivityBundle.get_show_launcher()
ActivityBundle.install()
ActivityBundle.install_mime_type()
ActivityBundle.uninstall()
ActivityBundle.is_user_activity()
get_bundle_instance()
- sugar.bundle.bundle module
- sugar.bundle.bundleversion module
- sugar.bundle.contentbundle module
ContentBundle
ContentBundle.MIME_TYPE
ContentBundle.__init__()
ContentBundle.get_name()
ContentBundle.get_library_version()
ContentBundle.get_locale()
ContentBundle.get_activity_start()
ContentBundle.get_icon()
ContentBundle.get_start_uri()
ContentBundle.get_bundle_id()
ContentBundle.get_activity_version()
ContentBundle.get_tags()
ContentBundle.install()
ContentBundle.uninstall()
ContentBundle.is_user_activity()
- sugar.bundle.helpers module
- Module contents
- sugar.datastore package
- sugar.dispatch package
- sugar.graphics package
- Submodules
- sugar.graphics.alert module
- sugar.graphics.animator module
- sugar.graphics.icon module
- Icons - GTK4
Icon
Icon.__init__()
Icon.do_snapshot()
Icon.do_measure()
Icon.get_icon_name()
Icon.set_icon_name()
Icon.get_file_name()
Icon.set_file_name()
Icon.get_pixel_size()
Icon.set_pixel_size()
Icon.get_fill_color()
Icon.set_fill_color()
Icon.get_stroke_color()
Icon.set_stroke_color()
Icon.get_xo_color()
Icon.set_xo_color()
Icon.get_badge_name()
Icon.set_badge_name()
Icon.get_alpha()
Icon.set_alpha()
Icon.get_scale()
Icon.set_scale()
Icon.get_badge_size()
Icon.get_pixbuf()
Icon.set_pixbuf()
Icon.get_gtk_image()
EventIcon
CanvasIcon
CellRendererIcon
get_icon_file_name()
get_icon_state()
get_surface()
- sugar.graphics.menuitem module
- sugar.graphics.objectchooser module
- sugar.graphics.palette module
Palette
Palette.__init__()
Palette.get_full_size_request()
Palette.popup()
Palette.popdown()
Palette.on_enter()
Palette.set_primary_text()
Palette.get_primary_text()
Palette.set_secondary_text()
Palette.get_secondary_text()
Palette.set_icon()
Palette.get_icon()
Palette.set_icon_visible()
Palette.get_icon_visible()
Palette.set_content()
Palette.get_label_width()
Palette.get_menu()
PaletteActionBar
- sugar.graphics.palettegroup module
- sugar.graphics.palettemenu module
- sugar.graphics.palettewindow module
MouseSpeedDetector
PaletteWindow
PaletteWindow.__init__()
PaletteWindow.destroy()
PaletteWindow.set_invoker()
PaletteWindow.get_invoker()
PaletteWindow.set_content()
PaletteWindow.is_up()
PaletteWindow.set_group_id()
PaletteWindow.get_group_id()
PaletteWindow.update_position()
PaletteWindow.get_full_size_request()
PaletteWindow.popup()
PaletteWindow.popdown()
PaletteWindow.on_invoker_enter()
PaletteWindow.on_invoker_leave()
PaletteWindow.on_enter()
PaletteWindow.on_leave()
PaletteWindow.get_rect()
Invoker
Invoker.ANCHORED
Invoker.AT_CURSOR
Invoker.BOTTOM
Invoker.RIGHT
Invoker.TOP
Invoker.LEFT
Invoker.__init__()
Invoker.attach()
Invoker.detach()
Invoker.get_position_for_alignment()
Invoker.get_position()
Invoker.get_alignment()
Invoker.has_rectangle_gap()
Invoker.draw_rectangle()
Invoker.notify_popup()
Invoker.notify_popdown()
Invoker.notify_mouse_enter()
Invoker.notify_mouse_leave()
Invoker.notify_right_click()
Invoker.notify_toggle_state()
Invoker.get_palette()
Invoker.set_palette()
Invoker.get_cache_palette()
Invoker.set_cache_palette()
Invoker.get_toggle_palette()
Invoker.set_toggle_palette()
Invoker.get_lock_palette()
Invoker.set_lock_palette()
Invoker.primary_text_clicked()
Invoker.get_rect()
Invoker.get_toplevel()
WidgetInvoker
WidgetInvoker.__init__()
WidgetInvoker.attach_widget()
WidgetInvoker.detach()
WidgetInvoker.get_rect()
WidgetInvoker.has_rectangle_gap()
WidgetInvoker.draw_rectangle()
WidgetInvoker.get_widget()
WidgetInvoker.set_widget()
WidgetInvoker.get_toplevel()
WidgetInvoker.notify_popup()
WidgetInvoker.notify_popdown()
CursorInvoker
ToolInvoker
TreeViewInvoker
- sugar.graphics.radiopalette module
- sugar.graphics.radiotoolbutton module
- sugar.graphics.style module
- Style
Font
Color
zoom()
apply_css_to_widget()
ZOOM_FACTOR
DEFAULT_SPACING
DEFAULT_PADDING
GRID_CELL_SIZE
LINE_WIDTH
STANDARD_ICON_SIZE
SMALL_ICON_SIZE
MEDIUM_ICON_SIZE
LARGE_ICON_SIZE
XLARGE_ICON_SIZE
FONT_SIZE
FONT_FACE
FONT_NORMAL
FONT_BOLD
FONT_NORMAL_H
FONT_BOLD_H
FONT_ITALIC
COLOR_BLACK
COLOR_WHITE
COLOR_TRANSPARENT
COLOR_PANEL_GREY
COLOR_SELECTION_GREY
COLOR_TOOLBAR_GREY
COLOR_BUTTON_GREY
COLOR_INACTIVE_FILL
COLOR_INACTIVE_STROKE
COLOR_TEXT_FIELD_GREY
COLOR_HIGHLIGHT
COLOR_PRIMARY
COLOR_SUCCESS
COLOR_WARNING
COLOR_ERROR
PALETTE_CURSOR_DISTANCE
TOOLBAR_ARROW_SIZE
MENU_WIDTH_CHARS
BORDER_RADIUS
SHADOW_BLUR
TRANSITION_DURATION
- sugar.graphics.toolbarbox module
- sugar.graphics.toolbox module
- sugar.graphics.combobox module
- sugar.graphics.toolcombobox module
- sugar.graphics.toggletoolbutton module
ToggleToolButton
ToggleToolButton.__init__()
ToggleToolButton.set_icon_name()
ToggleToolButton.get_icon_name()
ToggleToolButton.create_palette()
ToggleToolButton.get_palette()
ToggleToolButton.set_palette()
ToggleToolButton.get_palette_invoker()
ToggleToolButton.set_palette_invoker()
ToggleToolButton.set_tooltip()
ToggleToolButton.set_accelerator()
ToggleToolButton.get_accelerator()
ToggleToolButton.do_snapshot()
ToggleToolButton.do_clicked()
- sugar.graphics.toolbutton module
- ToolButton
setup_accelerator()
ToolButton
ToolButton.__init__()
ToolButton.set_tooltip()
ToolButton.get_tooltip()
ToolButton.get_hide_tooltip_on_click()
ToolButton.set_hide_tooltip_on_click()
ToolButton.set_accelerator()
ToolButton.get_accelerator()
ToolButton.set_icon_name()
ToolButton.get_icon_name()
ToolButton.set_icon_widget()
ToolButton.get_icon_widget()
ToolButton.set_label()
ToolButton.get_label()
ToolButton.create_palette()
ToolButton.get_palette()
ToolButton.set_palette()
ToolButton.get_palette_invoker()
ToolButton.set_palette_invoker()
ToolButton.do_snapshot()
ToolButton.set_active()
ToolButton.get_active()
- sugar.graphics.window module
- Window - GTK4 Port
UnfullscreenButton
Window
Window.__init__()
Window.reveal()
Window.is_fullscreen()
Window.fullscreen()
Window.unfullscreen()
Window.set_canvas()
Window.get_canvas()
Window.set_toolbar_box()
Window.get_toolbar_box()
Window.set_tray()
Window.add_alert()
Window.remove_alert()
Window.set_enable_fullscreen_mode()
Window.get_enable_fullscreen_mode()
Window.canvas
Window.toolbar_box
- sugar.graphics.xocolor module
- Module contents
- Graphics Module
XoColor
Icon
Icon.__init__()
Icon.do_measure()
Icon.do_snapshot()
Icon.get_alpha()
Icon.get_badge_name()
Icon.get_badge_size()
Icon.get_file_name()
Icon.get_fill_color()
Icon.get_gtk_image()
Icon.get_icon_name()
Icon.get_pixbuf()
Icon.get_pixel_size()
Icon.get_scale()
Icon.get_stroke_color()
Icon.get_xo_color()
Icon.set_alpha()
Icon.set_badge_name()
Icon.set_file_name()
Icon.set_fill_color()
Icon.set_icon_name()
Icon.set_pixbuf()
Icon.set_pixel_size()
Icon.set_scale()
Icon.set_stroke_color()
Icon.set_xo_color()
EventIcon
CanvasIcon
CellRendererIcon
get_icon_file_name()
get_surface()
get_icon_state()
- sugar.presence package
- Submodules
- sugar.presence.activity module
- sugar.presence.buddy module
BaseBuddy
BaseBuddy.__init__()
BaseBuddy.get_key()
BaseBuddy.set_key()
BaseBuddy.get_nick()
BaseBuddy.set_nick()
BaseBuddy.get_color()
BaseBuddy.set_color()
BaseBuddy.get_current_activity()
BaseBuddy.get_owner()
BaseBuddy.set_owner()
BaseBuddy.get_ip4_address()
BaseBuddy.set_ip4_address()
BaseBuddy.get_tags()
BaseBuddy.set_tags()
BaseBuddy.object_path()
Buddy
Owner
- sugar.presence.connectionmanager module
- sugar.presence.presenceservice module
PresenceService
PresenceService.__init__()
PresenceService.get_activity()
PresenceService.get_activity_by_handle()
PresenceService.get_buddy()
PresenceService.get_buddy_by_telepathy_handle()
PresenceService.get_owner()
PresenceService.share_activity()
PresenceService.get_preferred_connection()
PresenceService.get()
PresenceService.get_activities()
PresenceService.get_activities_async()
PresenceService.get_buddies()
PresenceService.get_buddies_async()
get_instance()
- sugar.presence.sugartubeconn module
- sugar.presence.tubeconn module
- Module contents
Submodules
sugar.env module
Calculates file-paths for the Sugar working environment
sugar.logger module
Logging service setup.
STABLE.
- sugar.logger.cleanup()[source]
Clean up the log directory, moving old logs into a numbered backup directory. We only keep _MAX_BACKUP_DIRS of these backup directories around; the rest are removed.
sugar.mime module
MIME helpers based on freedesktop specification.
STABLE.
sugar.network module
STABLE.
- class sugar.network.GlibTCPServer(*args: Any, **kwargs: Any)[source]
Bases:
TCPServer
Integrate socket accept into glib mainloop.
- allow_reuse_address = True
- request_queue_size = 20
- class sugar.network.ChunkedGlibHTTPRequestHandler(*args: Any, **kwargs: Any)[source]
Bases:
SimpleHTTPRequestHandler
RequestHandler class that integrates with Glib mainloop. It writes the specified file to the client in chunks, returning control to the mainloop between chunks.
- CHUNK_SIZE = 4096
- send_head()[source]
Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied to the outputfile by the caller unless the command was HEAD, and must be closed by the caller under all circumstances), or None, in which case the caller has nothing further to do.
** [dcbw] modified to send Content-disposition filename too
sugar.profile module
User settings/configuration loading.
- class sugar.profile.Profile(path)[source]
Bases:
object
Local user’s current options/profile information
The profile is also responsible for loading the user’s public and private ssh keys from disk.
- pubkey -- public ssh key
- privkey_hash -- SHA has of the child's public key
- property pubkey
- property privkey_hash
sugar.util module
Various utility functions
- sugar.util.unique_id(data='')[source]
Generate a likely-unique ID for whatever purpose
data – suffix appended to working data before hashing
Returns a 40-character string with hexidecimal digits representing an SHA hash of the time, a random digit within a constrained range and the data passed.
- Note: these are not crypotographically secure or
globally unique identifiers. While they are likely to be unique-enough, no attempt is made to make perfectly unique values.
- sugar.util.set_proc_title(title)[source]
Sets the process title so ps and top show more descriptive names. This does not modify argv[0] and only the first 15 characters will be shown.
- title – the title you wish to change the process
title to
Returns True on success. We don’t raise exceptions because if something goes wrong here it is not a big deal as this is intended as a nice thing to have for debugging
- class sugar.util.LRU(count, pairs=[])[source]
Bases:
object
Implementation of a length-limited O(1) LRU queue. Built for and used by PyPE: http://pype.sourceforge.net Copyright 2003 Josiah Carlson.
Module contents
Sugar Toolkit GTK4 Python
A modern GTK4 port of the Sugar Toolkit for Python activities.
This package provides the core functionality needed to create Sugar activities using GTK4, maintaining compatibility with Sugar’s educational framework while leveraging modern GTK4 features.
- Modules:
activity: Core activity classes and functionality graphics: Visual components, styling, and UI widgets bundle: Activity bundle management
- class sugar.Activity(*args: Any, **kwargs: Any)[source]
Bases:
Window
Initialise an Activity.
- Parameters:
handle (
ActivityHandle
) – instance providing the activity id and access to the presence service which may provide sharing for this applicationcreate_jobject (boolean) – DEPRECATED: define if it should create a journal object if we are not resuming. The parameter is ignored, and always will be created a object in the Journal.
- Signals:
- shared - the activity has been shared on a network in
order that other users may join,
- joined - the activity has joined with other instances of
the activity to create a shared network activity.
closing - the activity is about to close
Side effects:
sets the display DPI setting (resolution) to the Sugar screen resolution.
connects our “close-request” signal to our close handling.
creates a base Gtk.ApplicationWindow within this window.
creates activity service handling for this application.
When your activity implements
__init__()
, it must call theActivity
class__init__()
before anyActivity
specific code.- add_stop_button(button)[source]
Register an extra stop button. Normally not required. Use only when an activity has more than the default stop button.
- Parameters:
button (
Gtk.Button
) – a stop button
- busy()[source]
Show that the activity is busy. If used, must be called once before a lengthy operation, and
unbusy()
must be called after the operation completes.self.busy() self.long_operation() self.unbusy()
- can_close()[source]
Return whether
close()
is permitted.An activity may override this function to code extra checks before closing.
- close(skip_save=False)[source]
Save to the journal and stop the activity.
Activities should not override this method, but should implement
write_file()
to do any state saving instead. If the activity wants to control whether it can close, it should overridecan_close()
.
- copy()[source]
Make a copy of the journal object.
Activities may use this to ‘Keep in Journal’ the current state of the activity. A new journal object will be created for the running activity.
Activities should not override this method. Instead, like
save()
do any copy work that needs to be done inwrite_file()
.
- get_active()[source]
Get whether the activity is active. An activity may be made inactive by the shell as a result of another activity being active. An active activity accumulates usage metrics.
- Returns:
if the activity is active.
- Return type:
boolean
- get_activity_root()[source]
Deprecated. This part of the API has been moved out of this class to the module itself
- get_id()[source]
Get the activity id, a likely-unique identifier for the instance of an activity, randomly assigned when a new instance is started, or read from the journal object metadata when a saved instance is resumed.
- Returns:
the activity id
- Return type:
See also
create_activity_id()
andunique_id()
.
- get_max_participants()[source]
Get the maximum number of users that can share a instance of this activity. Should be configured in the activity.info file. When not configured, it will be zero.
- Returns:
the maximum number of participants
- Return type:
See also
get_max_participants()
inActivityBundle
.
- get_metadata()[source]
Get the journal object metadata.
- Returns:
the journal object metadata, or None if there is no object.
- Return type:
Activities can set metadata in write_file() using:
self.metadata['MyKey'] = 'Something'
and retrieve metadata in read_file() using:
self.metadata.get('MyKey', 'aDefaultValue')
Make sure your activity works properly if one or more of the metadata items is missing. Never assume they will all be present.
- get_preview()[source]
Get a preview image from the
canvas
, for use as metadata for the journal object. This should be what the user is seeing at the time.- Returns:
image data in PNG format
- Return type:
Activities may override this method, and return a string with image data in PNG format with a width and height of
PREVIEW_SIZE
pixels.The method creates a Cairo surface for the canvas widget, draws on it, then resizes to a surface with the preview size.
Get whether the activity is shared.
- Returns:
the activity is shared.
- Return type:
Get the shared activity of type
sugar.presence.activity.Activity
, or None if the activity is not shared, or is shared and not yet joined.- Returns:
- instance of
the shared activity or None
- Return type:
- handle_view_source()[source]
An activity may override this method to show additional information in the View Source window. Examples can be seen in Browse and TurtleArt.
- Raises:
- invite(account_path, contact_id)[source]
Invite a buddy to join this activity.
- Parameters:
account_path – account path
contact_id – contact ID
- Side Effects:
Calls
share()
to privately share the activity if it wasn’t shared before.
- property metadata
Get the journal object metadata.
- Returns:
the journal object metadata, or None if there is no object.
- Return type:
Activities can set metadata in write_file() using:
self.metadata['MyKey'] = 'Something'
and retrieve metadata in read_file() using:
self.metadata.get('MyKey', 'aDefaultValue')
Make sure your activity works properly if one or more of the metadata items is missing. Never assume they will all be present.
- notify_user(summary, body)[source]
Display a notification with the given summary and body. The notification will go under the activities icon in the frame.
Note: In GTK4/Flatpak, this uses the portal notification system.
- read_file(file_path)[source]
Subclasses implement this method if they support resuming objects from the journal. ‘file_path’ is the file to read from.
You should immediately open the file from the file_path, because the file_name will be deleted immediately after returning from
read_file()
.Once the file has been opened, you do not have to read it immediately: After you have opened it, the file will only be really gone when you close it.
Although not required, this is also a good time to read all meta-data: the file itself cannot be changed externally, but the title, description and other metadata[‘tags’] may change. So if it is important for you to notice changes, this is the time to record the originals.
- Parameters:
file_path (str) – the file path to read
- run_main_loop()[source]
Run the main loop for the activity.
Note: In GTK4, this is typically handled by the application, but we keep this for compatibility.
- save()[source]
Save to the journal.
This may be called by the
close()
method.Activities should not override this method. This method is part of the public API of an activity, and should behave in standard ways. Use your own implementation of write_file() to save your activity specific data.
- set_active(active)[source]
Set whether the activity is active. An activity may declare itself active or inactive, as can the shell. An active activity accumulates usage metrics.
- Parameters:
active (boolean) – if the activity is active.
- set_canvas(canvas)[source]
Set the
canvas
.- Parameters:
canvas (
Gtk.Widget
) – the widget used as canvas
- set_max_participants(participants)[source]
Set the maximum number of users that can share a instance of this activity. An activity may use this method instead of or as well as configuring the activity.info file. When both are used, this method takes precedence over the activity.info file.
- Parameters:
participants (int) – the maximum number of participants
Request that the activity be shared on the network.
- Parameters:
private (bool) – True to share by invitation only, False to advertise as shared to everyone.
Once the activity is shared, its privacy can be changed by setting the
private
property of thesugar.presence.activity.Activity
class.
- unbusy()[source]
Show that the activity is not busy. An equal number of calls to
unbusy()
are required to balance the calls tobusy()
.
- write_file(file_path)[source]
Subclasses implement this method if they support saving data to objects in the journal. ‘file_path’ is the file to write to.
If the user did make changes, you should create the file_path and save all document data to it.
Additionally, you should also write any metadata needed to resume your activity. For example, the Read activity saves the current page and zoom level, so it can display the page.
Note: Currently, the file_path WILL be different from the one you received in
read_file()
. Even if you kept the file_path fromread_file()
open until now, you must still write the entire file to this file_path.- Parameters:
file_path (str) – complete path of the file to write
- class sugar.SimpleActivity(*args: Any, **kwargs: Any)[source]
Bases:
Activity
A simple activity implementation for quick prototyping.
This provides a basic activity with a toolbar and content area.
- class sugar.XoColor(color_string=None)[source]
Bases:
object
Defines color for XO
This class represents a pair of colors (stroke and fill) that can be used throughout Sugar activities. Colors can be parsed from strings, loaded from user settings, or chosen randomly.
- Parameters:
color_string (str, optional) – Color specification in one of these formats: - “stroke_hex,fill_hex” (e.g., “#FF0000,#00FF00”) - “white” for white theme - “insensitive” for disabled/grayed theme - None to use user’s color from settings or random if not available
Examples
>>> #from string >>> color = XoColor("#FF0000,#00FF00") >>> print(color.get_stroke_color()) # "#FF0000" >>> print(color.get_fill_color()) # "#00FF00"
>>> # create user's color (or random if not set) >>> color = XoColor()
>>> # themed colors >>> white_color = XoColor("white") >>> disabled_color = XoColor("insensitive")
- classmethod from_string(color_string)[source]
Create XoColor from string representation.
- Parameters:
color_string (str) – Color string to parse
- Returns:
New XoColor instance
- Return type:
- Raises:
ValueError – If color_string cannot be parsed
- classmethod get_random_color()[source]
Get a random XO color.
- Returns:
Random XoColor instance from the standard palette
- Return type:
- class sugar.Icon(*args: Any, **kwargs: Any)[source]
Bases:
Widget
Basic Sugar icon widget for GTK4.
Displays themed icons with Sugar’s color customization features.
- Properties:
icon_name (str): Icon name from theme file_name (str): Path to icon file pixel_size (int): Size in pixels fill_color (str): Fill color as hex string stroke_color (str): Stroke color as hex string xo_color (XoColor): Sugar color pair badge_name (str): Badge icon name alpha (float): Icon transparency (0.0-1.0) scale (float): Icon scale factor sensitive (bool): Whether icon appears sensitive
- __init__(icon_name: str | None = None, file_name: str | None = None, pixel_size: int = 48, **kwargs)[source]
- do_measure(orientation: gi.repository.Gtk.Orientation, for_size: int) Tuple[int, int, int, int] [source]
GTK4 size request method.
- class sugar.EventIcon(*args: Any, **kwargs: Any)[source]
Bases:
Icon
Icon widget with mouse event handling using GTK4 gestures.
- Signals:
clicked: Emitted when icon is clicked pressed: Emitted when icon is pressed released: Emitted when icon is released activate: Emitted when icon is activated
- class sugar.MenuItem(*args: Any, **kwargs: Any)[source]
Bases:
Button
A Sugar-style menu item with icon and text support.
In GTK4, this replaces the deprecated ImageMenuItem with a Button that can be used in menus and popover menus.
- Parameters:
- __init__(text_label: str | None = None, icon_name: str | None = None, text_maxlen: int = 60, xo_color=None, file_name: str | None = None)[source]
- get_accelerator() str | None [source]
Get the current accelerator string.
- Returns:
Current accelerator or None
- Return type:
- get_text() str [source]
Get the current text of the menu item.
- Returns:
Current text or empty string
- Return type: