Skip to main content

A GTK4 port of the Sugar Toolkit for Python activities

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sugar_toolkit_gtk4-1.1.4.tar.gz (225.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sugar_toolkit_gtk4-1.1.4-py3-none-any.whl (195.0 kB view details)

Uploaded Python 3

File details

Details for the file sugar_toolkit_gtk4-1.1.4.tar.gz.

File metadata

  • Download URL: sugar_toolkit_gtk4-1.1.4.tar.gz
  • Upload date:
  • Size: 225.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.14

File hashes

Hashes for sugar_toolkit_gtk4-1.1.4.tar.gz
Algorithm Hash digest
SHA256 640ad6f6e019668e4bcb82912a9a57299a7230b1bef35d911a4ce64514e7064a
MD5 b4411f8899ea73cbc5cd504b48eb0d4f
BLAKE2b-256 b51610e8e256885920306cf8c943c7c0ec76d87b8aaf77c874c753c76886c969

See more details on using hashes here.

File details

Details for the file sugar_toolkit_gtk4-1.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for sugar_toolkit_gtk4-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b8dcd30ab8f5527a80ed6acbe27fcc2b701457fc941b68f38573422b17d7d943
MD5 bed6d722396a5d2aef22206004052e20
BLAKE2b-256 4fc37e315d2d54da0713a6b0c4dc0c036ba7b5cc073bff402f41d5ebd7e9400b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page