PROVIDER - the widget toolkit of the Linux desktop
GTK
GTK began in 1997 as the GIMP toolkit and now underpins the GNOME desktop, adding object orientation to C through GObject, with GTK4 bringing GPU-accelerated rendering and bindings for 3 or more languages including gtkmm, PyGObject and gtk-rs; non-Linux polish and migration effort are the main limits.
Detailed Notes
Pros 5 items
Cons 4 items
Service Overview
GTK (GIMP Toolkit) appeared in 1997 as the interface toolkit for GIMP and later became the foundation of the GNOME desktop, now maintained by the GNOME project. It is written in C on top of GObject, which gives C object-oriented capabilities.
In the languages and frameworks category it is the standard for Linux desktop interfaces and the common base for many utilities shipped by distributions.
Key Strengths
- Solid ecosystem base: GNOME and a large set of Linux desktop apps run on GTK
- GObject system: signals, properties and type registration provide full object orientation
- GTK4 rendering upgrade: GPU acceleration and a new render node tree smooth animation and high-DPI output
- Multiple bindings: gtkmm, PyGObject and gtk-rs cover C++, Python and Rust
- Modern component library: libadwaita supplies widgets that follow GNOME design guidelines
Product Ecosystem
Framework and components
The GTK4 core, libadwaita, the GSK rendering layer and the Gdk abstraction, with GtkBuilder describing interfaces in XML.
Language bindings
gtkmm for C++, PyGObject for Python, gtk-rs for Rust and native Vala bindings.
Tooling
Glade and Cambalache provide visual design, and the Builder toolchain compiles resources.
Limitations
- Cross-platform gaps: Linux is best supported, while Windows and macOS need packaging and theme work
- Scattered documentation: API reference is complete but systematic tutorials are fewer
- C boilerplate: GObject scaffolding is heavy and slower than the bindings
- Migration cost: GTK3 to GTK4 changed widgets and theming substantially
Use Cases
- Linux desktop applications (★★★★★): the most natural GNOME integration
- Open source tools and utilities (★★★★★): distribution packaging and dependencies are mature
- Python desktop tools (★★★★): PyGObject turns a script into an interface quickly
- Commercial Windows or macOS software (★★★): assess look and distribution first
Pricing
| Item | Price | Notes |
|---|---|---|
| GTK library and docs | $0 | Open source under LGPL, free to link |
| Language bindings | $0 | gtkmm, PyGObject and gtk-rs are all open source |
| Development tools | $0 | GNOME Builder and Glade are free |
Everything is free; the cost is learning C and GObject plus cross-platform adaptation.
FAQ
- GTK or Qt? Pick GTK for Linux-first desktop apps that want the GNOME look, and Qt when Windows and embedded targets need a consistent experience.
- Must it be written in C? No. PyGObject suits scripted tools and gtk-rs suits Rust projects that value safety.
- Is GTK4 worth upgrading to? New projects should start with GTK4 and libadwaita, while older ones must estimate how many widgets need replacing. More options are under languages and frameworks.
Code Examples
A minimal GTK4 window in C
#include <gtk/gtk.h>
static void on_activate(GtkApplication *app, gpointer user_data) {
GtkWidget *window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Hello GTK");
gtk_window_set_default_size(GTK_WINDOW(window), 320, 200);
GtkWidget *label = gtk_label_new("Hello, GTK4");
gtk_window_set_child(GTK_WINDOW(window), label);
gtk_window_present(GTK_WINDOW(window));
}
int main(int argc, char **argv) {
GtkApplication *app = gtk_application_new("org.example.hello",
G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect(app, "activate", G_CALLBACK(on_activate), NULL);
int status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
gtk_application_window_new creates the window, g_signal_connect binds the activate signal, and g_object_unref releases the object.
The same window in PyGObject
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
def on_activate(app):
win = Gtk.ApplicationWindow(application=app, title="Hello GTK")
win.set_default_size(320, 200)
win.set_child(Gtk.Label(label="Hello, PyGObject"))
win.present()
app = Gtk.Application(application_id="org.example.hello")
app.connect("activate", on_activate)
app.run()
The Python binding removes boilerplate, and require_version pins GTK 4.
Community & Resources
- GTK: documentation, downloads and design notes
- GNOME: the desktop ecosystem and design guidelines
- GitHub GTK topic: open apps and components
- GitHub PyGObject topic: Python binding practice
- GitHub Qt topic: the other cross-platform GUI framework