A GTK4/Adwaita application template built with Python and Blueprint.
hello-gtk-python/
├── meson.build # Root build definition
├── com.example.HelloGtkPython.json # Flatpak manifest
├── pyproject.toml # Python project metadata
├── rename.py # Project renamer script
├── data/
│ ├── com.example.HelloGtkPython.desktop.in # Desktop entry
│ ├── com.example.HelloGtkPython.metainfo.xml.in # AppStream metadata
│ ├── com.example.HelloGtkPython.gschema.xml # GSettings schema
│ └── icons/ # App icons (scalable + symbolic)
├── po/ # i18n translations
└── src/
├── meson.build # Blueprint compile + GResource + Python install
├── hello-gtk-python.in # Meson-configured launcher script
├── main.py # Entry point
├── application.py # Adw.Application subclass
├── window.py # Adw.ApplicationWindow subclass
└── window.blp # Blueprint UI definition
- Python 3.10+
- GTK 4
- libadwaita 1
- Meson >= 0.62
- blueprint-compiler >= 0.14
- PyGObject
- uv
Install uv (Python package manager):
curl -LsSf https://astral.sh/uv/install.sh | shCheck if everything is installed:
python3 check-deps.pyOn Ubuntu/Debian:
sudo apt install python3-gi python3-gi-cairo gir1.2-adw-1 meson ninja-build blueprint-compilerOn Fedora:
sudo dnf install python3-gobject python3-gobject-devel gtk4-devel libadwaita-devel meson ninja-build blueprint-compiler# Initial setup (one time)
uv venv --system-site-packages
uv sync
meson setup build
# Build and run
meson compile -C build && ninja -C build runThe --system-site-packages flag gives the venv access to PyGObject (system package).
Meson auto-detects the .venv Python, so the launcher and any uv add dependencies
share the same environment. Changes to .blp files are recompiled on each build.
To add Python dependencies:
uv add requests # or any pip packageRequires the GNOME 48 SDK:
# Install runtime and SDK (one time)
flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --user flathub org.gnome.Sdk//48 org.gnome.Platform//48
# Build and install
flatpak-builder --user --install --force-clean build-flatpak com.example.HelloGtkPython.json
# Run
flatpak run com.example.HelloGtkPythonRun the rename script to replace all template names with your own:
uv run rename.pyIt will prompt for:
- Project name (kebab-case, e.g.
my-cool-app) - Application ID (e.g.
com.mycompany.MyCoolApp) - Display name (e.g.
My Cool App)
This renames all files and replaces every instance of hello-gtk-python, HelloGtkPython, com.example.HelloGtkPython, etc. throughout the project. Any existing build directories are automatically cleaned up.
After renaming, re-run the initial setup:
uv venv --system-site-packages
uv sync
meson setup build
meson compile -C build && ninja -C build runNote: Commands elsewhere in this README that reference hello-gtk-python or
com.example.HelloGtkPython will need to use your new project name and application ID instead
(e.g. ninja -C build my-cool-app-pot, flatpak run com.mycompany.MyCoolApp).
Wrap user-visible strings with _() to make them translatable:
- Blueprint:
label: _("Hello, World!"); - Python:
_('Hello, World!')(addfrom gettext import gettext as _at the top)
Any new source files with _() strings must be listed in po/POTFILES.
After adding or changing translatable strings:
# Regenerate the .pot template and merge into .po files
ninja -C build hello-gtk-python-pot
ninja -C build hello-gtk-python-update-poTo add a new language (e.g. French):
- Create
po/fr.pofrom the.pottemplate:msginit -i po/hello-gtk-python.pot -o po/fr.po -l fr - Add
frtopo/LINGUAS - Translate the
msgstrentries inpo/fr.po
The build compiles .po files into binary .mo files automatically.
- GTK 4 — Python API Reference
- Libadwaita — Python API Reference
- Blueprint — UI Language
- PyGObject
- Meson Build System
- Flatpak Builder
- GNOME Human Interface Guidelines
MIT