GTK (formerly GTK+,[4] GIMP ToolKit) is a free and open-source cross-platform widget toolkit for creating graphical user interfaces (GUIs).[5] It is licensed under the terms of the GNU Lesser General Public License, allowing both free and proprietary software to use it. It is one of the most popular toolkits for the Wayland and X11 windowing systems.[6]

The GTK library contains a set of graphical control elements (widgets); version 3.22.16 contains 186 active and 36 deprecated widgets.[7] GTK is an object-oriented widget toolkit written in the programming language C; it uses GObject, that is the GLib object system, for the object orientation. While GTK is mainly for windowing systems based on X11 and Wayland, it works on other platforms, including Microsoft Windows (interfaced with the Windows API), and macOS (interfaced with Quartz). There is also an HTML5 back-end named Broadway.[8][9]

GTK can be configured to change the look of the widgets drawn; this is done using different display engines. Several display engines exist which try to emulate the look of the native widgets on the platform in use.

Starting with version 2.8, released in 2005, GTK began the transition to using Cairo to render most of its graphical control elements widgets.[10] Since GTK version 3.0, all rendering is done using Cairo.[citation needed]

On 26 January 2018 at, Matthias Clasen gave an overview of the current state of GTK 4 development, including a high-level explanation of how rendering and input worked in GTK 3, what changes are being made in GTK 4 (>3.90), and why.[11] On 6 February 2019 it was announced that GTK 4 will drop the “+” from the project's name.[4]

GDK acts as a wrapper around the low-level functions provided by the underlying windowing and graphics systems.

GSK is the rendering and scene graph API for GTK. GSK lies between the graphical control elements (widgets) and the rendering. GSK was finally merged into GTK version 3.90 released March 2017.

GtkInspector was introduced with version 3.14.[12][13] GtkInspector can only be invoked after installing the development package /.

There are several GUI designers for GTK. The following projects are active as of July 2011:

GtkBuilder allows user interfaces to be designed without writing code. The interface is described in an Extensible Markup Language (XML) file, which is then loaded at runtime and the objects created automatically. The Glade Interface Designer allows creation of the user interface in a what you see is what you get (WYSIWYG) manner. The description of the user interface is independent from the programming language being used.

A library written in one programming language may be used in another language if bindings are written; GTK has a range of bindings for various languages.[16]

Gtk# is a set of .NET Framework bindings for the GTK graphical user interface (GUI) toolkit and assorted GNOME libraries. The library facilitates building graphical GNOME applications using Mono or any other compliant Common Language Runtime (CLR). Gtk# is an event-driven system like any other modern windowing library where every widget allows associating handler methods, which get called when certain events occur.

Applications built using Gtk# will run on many platforms including Linux, Windows and macOS. The Mono packages for Windows include GTK, Gtk# and a native theme to make applications look like native Windows applications. Starting with Mono 1.9, running Gtk# applications on macOS no longer requires running an X11 server.[18]

Glade Interface Designer can be used with the Glade# bindings to easily design GUI applications. A GUI designer named Stetic is integrated with the MonoDevelop integrated development environment (IDE).

In addition to support the standard GTK/GNOME stack of development tools, the gtk-dotnet.dll assembly provides a bridge to consume functionality available on the .NET stack. At this point this includes the functionality to use System.Drawing to draw on a widget.

As of September 2020, Gtk# support for Gtk3 remains in the preview phase and forked projects, such as , have been founded to provide full Gtk3 support for C# and other CLI languages. The lack of a released version of Gtk# with support for Gtk3 was cited as a reason to remove the Banshee media player in Ubuntu 12.04.[19]

GTK is mainly developed by The GNOME Project, which also develops the GNOME Development Platform and the GNOME Desktop Environment.[20]

GTK development is loosely managed. Discussion chiefly occurs on several public mailing lists.[21] GNOME developers and users gather at an annual GNOME Users And Developers European Conference GUADEC meeting to discuss GNOME's current state and future direction.[22] GNOME incorporates standards and programs from to better interoperate with other desktops.

On 1 September 2016 a post on the GTK development blog denoted, among other things, the future numbering scheme of GTK.[24] GTK version 3.22 from autumn 2016 shall be the last 3.x release.[clarification needed] Version 3.24 was introduced in Fall 2018 with the delay of GTK 4. [25] After that all resources will move to the GTK 4 development series with the version names 3.90, 3.92, etc. Even as the 4.x series enters development, notable applications still use GTK 2.x and have not been ported to 3.22. Regarding the future of legacy software using GTK, there was no collective project to port GTK 2.x software to 3.22. Version 3.24 is in longterm support and the actual and Future base of programs like gimp 3.0 and Inkscape 1.0.[26] So for developers is the choice stable GTK 3.24 with bugfix or GTK 4 with changes and new features in future development.

GTK (and GNOME, GLib, etc.) formerly utilized the GNU Build System (named Autotools) as the build automation system of choice.

Since 14 Aug 2017, the master branch of GTK has been built with Meson, and the Autotools build system files have been dropped.[27]

The most common criticism of GTK is the lack of backward-compatibility in major updates, most notably in the application programming interface (API)[28] and theming.[29]

The compatibility breaks between minor releases during the GTK 3.x development cycle was explained by Benjamin Otte as due to strong pressures to innovate, such as providing the features modern users expect and supporting the increasingly influential Wayland display server protocol. With the release of GTK 4, the pressure from the need to innovate will have been released and the balance between stability and innovation will tip toward stability.[30] Similarly, recent changes to theming are specifically intended to improve and stabilise that part of the API, meaning some investment now should be rewarded later.

The GTK support for Wayland, co-requisites applications to be adapted to Wayland also
Screenshot of GIMP 2.8 - GTK is responsible for managing the interface components of the program, including the menus, buttons, and input fields.

Some notable applications that use or once used GTK as a widget toolkit include:

GTK programs can be run on desktop environments based on X11 and Wayland, or window managers even those not made with GTK, provided the needed libraries are installed; this includes macOS if is installed. GTK can be also run on Microsoft Windows, where it is used by some popular cross-platform applications like Pidgin and GIMP. wxWidgets, a cross-platform GUI tool-kit, uses GTK on Linux by default.[36] Other ports include DirectFB (used by the Debian installer, for example) and ncurses.[37]

For syntax highlighting there is GtkSourceView, "source code editing widget". GtkSourceView is maintained by GNOME separately from GTK as a library: . There are plans to rename to gsv.

GtkSpell is a library separate from GTK. GtkSpell depends on GTK and Enchant. Enchant is a wrapper for ispell, hunspell, etc, the actual spell checker engine/software. GtkSpell uses GTK's GtkTextView widget, to highlight misspelled words and offer replacement.

The following code presents a graphical GTK hello-world program in the C programming language. This program has a window with the title "Hello, world!" and a label with similar text.

/* Connect our handler to the "activate" callback, which will be called * when the application is activated by the user, e.g. on first start */

Needs installing the libraries first in Debian or derivatives: $ sudo apt-get install libgtk-4-dev

Using pkg-config in a Unix shell, this code can be compiled with the following command:

$ cc -Wall $(pkg-config --cflags --libs gtk4) helloworld.c -o helloworld

GTK was originally designed and used in the GNU Image Manipulation Program (GIMP) as a replacement of the Motif toolkit; at some point Peter Mattis became disenchanted with Motif and began to write his own GUI toolkit named the GIMP toolkit and had successfully replaced Motif by the 0.60 release of GIMP.[38] Finally GTK was re-written to be object-oriented and was renamed GTK+.[39] This was first used in the 0.99 release of GIMP. GTK was subsequently adopted for maintenance by the GNOME Foundation, which uses it in the GNOME desktop environment.

The GTK 2.0.0 release series introduced new features which include improved text rendering using Pango, a new theme engine, improved accessibility using the Accessibility Toolkit, transition to Unicode using UTF-8 strings, and a more flexible API. Starting with version 2.8, GTK 2 depends on the Cairo graphics library for rendering vector graphics.

GTK version 3.0.0 included revised input device handling, support for themes written with CSS-like syntax, and the ability to receive information about other opened GTK applications.

The '+' was dropped returning to simply 'GTK' in February 2019 during a Hackathon.[40]

HP stated that their goal was to merge the needed OpenVMS changes into the GTK Version 1.3 development stream,[47] however this never materialised. The latest version of GTK for OpenVMS is version 1.2.10.[48]

One of the cardinal novelties implemented during the GTK 4 development cycle (i.e. GTK 3.92, etc.) has been the delegation of functionality to ancillary objects instead of encoding it into the base classes provided by GTK.

In 2018-Jan-26 at Matthias Clasen gave an overview of the then current state of GTK 4 development, including a high-level explanation of how rendering and input worked in GTK 3, what changes were being made to GTK 4, and the reasons for those changes. Examples of things that have become possible with GTK 4 were given as well.[49]