Linux/Unix

../../_images/gtk.png

The Toga backend for Linux (and other Unix-like operating systems) is toga-gtk.

Qt support

Toga does not currently have a Qt backend for KDE-based desktops. However, we would like to add one; see this ticket for details. If you would like to contribute, please get in touch on that ticket, on Mastodon or on Discord.

GTK on Windows and macOS

Although GTK can be installed on Windows and macOS, and the toga-gtk backend may work on those platforms, this is not officially supported by Toga. We recommend using toga-winforms on Windows, and toga-cocoa on macOS.

Prerequisites

toga-gtk requires GTK 3.22 or newer. Most testing occurs with GTK 3.24 as this is the version that has shipped with all versions of Ubuntu since Ubuntu 20.04, and all versions of Fedora since Fedora 29.

The system packages that provide GTK must be installed manually:

These instructions are different on almost every version of Linux and Unix; here are some of the common alternatives:

Ubuntu / Debian

(venv) $ sudo apt update
(venv) $ sudo apt install git build-essential pkg-config python3-dev libgirepository1.0-dev libcairo2-dev gir1.2-gtk-3.0 libcanberra-gtk3-module

Fedora

(venv) $ sudo dnf install git gcc make pkg-config python3-devel gobject-introspection-devel cairo-gobject-devel gtk3 libcanberra-gtk3

Arch / Manjaro

(venv) $ sudo pacman -Syu git base-devel pkgconf python3 gobject-introspection cairo gtk3 libcanberra

OpenSUSE Tumbleweed

(venv) $ sudo zypper install git patterns-devel-base-devel_basis pkgconf-pkg-config python3-devel gobject-introspection-devel cairo-devel gtk3 'typelib(Gtk)=3.0' libcanberra-gtk3-module

FreeBSD

(venv) $ sudo pkg update
(venv) $ sudo pkg install git gcc cmake pkgconf python3 gobject-introspection cairo gtk3 libcanberra-gtk3

If you’re not using one of these, you’ll need to work out how to install the developer libraries for python3, cairo, and gobject-introspection (and please let us know so we can improve this documentation!)

Some widgets (most notably, the WebView and MapView widgets) have additional system requirements. See the documentation of those widgets for details.

Toga does not currently support GTK 4.

Installation

toga-gtk is installed automatically on any Linux machine (machines that report sys.platform == 'linux'), or any FreeBSD machine (machines that report sys.platform == 'freebsd*'). It can be manually installed by running:

$ python -m pip install toga-gtk

Implementation details

The toga-gtk backend uses the GTK3 API.

The native APIs are accessed using the PyGObject binding.