Skip to main content

sugar-toolkit-gtk4

A modern GTK4 port of the Sugar Toolkit for Python activities.

Project Status

This project is a ground-up reimplementation of the Sugar Toolkit using GTK4 and modern Python practices. We're maintaining compatibility with Sugar's core concepts while leveraging GTK4's improved APIs.

Installation

From Source

git clone https://github.com/sugarlabs/sugar-toolkit-gtk4.git
cd sugar-toolkit-gtk4
pip install -e .

Development Setup

make install

Quick Start

from sugar4.activity import SimpleActivity
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk

class MyActivity(SimpleActivity):
    def __init__(self):
        super().__init__()

        # Your activity code here
        label = Gtk.Label(label="Hello, Welcome GTK4!")
        self.set_canvas(label)

def main():
    """Run the activity with proper GTK4 application lifecycle."""
    app = Gtk.Application(application_id='org.sugarlabs.TestActivity')

    def on_activate(app):
        activity = MyActivity()
        app.add_window(activity)
        activity.present()

    app.connect('activate', on_activate)
    return app.run()

if __name__ == '__main__':
    main()

Development

Running Tests

make test

Running with Coverage

make test-coverage

Code Formatting

make format

Building Package

make build

Running Examples

make example

Makefile Usage

The project includes a comprehensive Makefile with targets for all development, testing, and packaging workflows. Use make help to see all available targets.

Installation and Setup

make install          # Install package in development mode
make dev-setup        # Complete development environment setup

Testing and Quality Assurance

make test             # Run all tests
make test-coverage    # Run tests with HTML coverage report
make format           # Format code with black
make format-check     # Check code formatting without changes
make dev-test         # Run full development test suite

Building and Packaging

make build            # Build wheel and source distributions
make dist             # Alias for build
make tarball          # Create source tarball
make check            # Verify package integrity with twine
make dev-build        # Clean, build, and check package

Publishing

make upload-test      # Upload to Test PyPI
make upload           # Upload to production PyPI

Utilities

make clean            # Remove build artifacts and cache files
make example          # Run the basic activity example
make test-toolkit     # Test toolkit installation (python -m sugar)
make ci-test          # Simulate complete CI pipeline locally
make help             # Show all available targets with descriptions

Development Workflow Examples

Setting up for development:

make dev-setup        # Install everything needed
make test             # Verify setup works

Before committing changes:

make dev-test         # Run full test suite with formatting checks

Creating a release:

make dev-build        # Clean build and verify package integrity
make tarball          # Create source distribution
make check            # Final verification before upload

Testing the complete CI workflow locally:

make ci-test          # Runs the full CI pipeline simulation

Dev Tips

  • Run the examples with:
 GTK_DEBUG=interactive QT_QPA_PLATFORM=xcb GDK_BACKEND=x11 \
SUGAR_BUNDLE_PATH="$(pwd)/examples" \
SUGAR_BUNDLE_ID="org.sugarlabs.SugarTextEditor" \
SUGAR_BUNDLE_NAME="Sugar Text Editor" \
SUGAR_ACTIVITY_ROOT="/tmp/sugar_text_editor" \
python examples/activity_examples.py

Requirements

  • Python 3.8+
  • GTK4
  • PyGObject 3.42+
  • GObject Introspection

License

LGPL-2.1-or-later

GTK4 App Bundling Example

See examples/gtk4_bundle_test/ for a minimal example of bundling a GTK4 Sugar activity using Flatpak.

  • Includes a simple activity (main.py), Flatpak manifest, and build/run instructions.
  • To try it:
    1. Install Flatpak and the GNOME SDK (see the example README).
    2. Build and run the bundle as described in the example.

Metadata

Release files for sugar-toolkit-gtk4 1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sugar-toolkit-gtk4 1.1.4
File Size Uploaded Provenance Actions
sugar_toolkit_gtk4-1.1.4.tar.gz 225.4 kB Without provenance Details for sugar_toolkit_gtk4-1.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sugar-toolkit-gtk4 1.1.4
File Interpreter ABI Platform Actions
sugar_toolkit_gtk4-1.1.4-py3-none-any.whl Python 3 none any Details for sugar_toolkit_gtk4-1.1.4-py3-none-any.whl

Total release size: 420.4 kB

Release files / sugar_toolkit_gtk4-1.1.4.tar.gz

Download URL sugar_toolkit_gtk4-1.1.4.tar.gz
Size 225.4 kB
Tags Source
SHA-256 checksum
How to use checksums
640ad6f6e019668e4bcb82912a9a57299a7230b1bef35d911a4ce64514e7064a
BLAKE2b-256 checksum
How to use checksums
b51610e8e256885920306cf8c943c7c0ec76d87b8aaf77c874c753c76886c969
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.14

Release files / sugar_toolkit_gtk4-1.1.4-py3-none-any.whl

Download URL sugar_toolkit_gtk4-1.1.4-py3-none-any.whl
Size 195.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8dcd30ab8f5527a80ed6acbe27fcc2b701457fc941b68f38573422b17d7d943
BLAKE2b-256 checksum
How to use checksums
4fc37e315d2d54da0713a6b0c4dc0c036ba7b5cc073bff402f41d5ebd7e9400b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.14

Security for sugar-toolkit-gtk4 1.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page