Linux/Unix¶
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. This requirement can be met with with all
versions of Ubuntu since 18.04, and all versions of Fedora since Fedora 26.
Toga receives the most testing with GTK 3.24. 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 18.04+ / Debian 10+
(venv) $ sudo apt update
(venv) $ sudo apt install pkg-config python3-dev libgirepository1.0-dev libcairo2-dev gir1.2-webkit2-4.0 libcanberra-gtk3-module
Fedora
(venv) $ sudo dnf install pkg-config python3-devel gobject-introspection-devel cairo-gobject-devel webkit2gtk3 libcanberra-gtk3
Arch / Manjaro
(venv) $ sudo pacman -Syu git pkgconf gobject-introspection cairo webkit2gtk libcanberra
FreeBSD
(venv) $ sudo pkg update
(venv) $ sudo pkg install gobject-introspection cairo webkit2-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!)
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.