CINXE.COM
The GTK Project - A free and open-source cross-platform widget toolkit
<!DOCTYPE html><html lang="en"dir="ltr"><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1,shrink-to-fit=no"><meta http-equiv="X-UA-Compatible"content="ie=edge"><meta name="theme-color"content="#ffffff"><meta name="apple-mobile-web-app-status-bar-style"content="#ffffff"><meta name="generator"content="Jekyll v4.0.1"><meta name="author"content="The GTK Team"><meta name="keywords"content="gtk, gtk, gimp, gnome, toolkit, user interface"><title>The GTK Project - A free and open-source cross-platform widget toolkit</title><meta itemprop="description"name="description"content="GTK is a free and open-source cross-platform widget toolkit for creating graphical user interfaces."><meta property="og:locale"content="en_US"><meta property="og:type"content="article"><meta property="og:title"content="The GTK Project - A free and open-source cross-platform widget toolkit"><meta property="og:url"content="https://www.gtk.org/"><meta property="og:image"content="/assets/img/logo-gtk.png"><meta property="og:site_name"content="The GTK Team"><meta property="og:description"content="GTK is a free and open-source cross-platform widget toolkit for creating graphical user interfaces."><meta property="twitter:title"content="The GTK Project - A free and open-source cross-platform widget toolkit"><meta property="twitter:description"content="GTK is a free and open-source cross-platform widget toolkit for creating graphical user interfaces."><meta name="twitter:site"content="@"><meta name="twitter:creator"content="@"><meta name="twitter:card"content="summary"><link rel="apple-touch-icon"sizes="180x180"href="https://www.gtk.org/assets/img/icons/apple-touch-icon.png"><link rel="icon"type="image/png"sizes="32x32"href="https://www.gtk.org/assets/img/icons/favicon-32x32.png"><link rel="icon"type="image/png"sizes="16x16"href="https://www.gtk.org/assets/img/icons/favicon-16x16.png"><link rel="canonical"href="https://www.gtk.org/"><link rel="stylesheet"href="https://www.gtk.org/assets/@fortawesome/fontawesome-free/css/all.min.css"type="text/css"media="screen"><link rel="stylesheet"href="https://www.gtk.org/assets/css/markdown.css"type="text/css"media="screen"><link rel="stylesheet"href="https://www.gtk.org/assets/css/theme.css"type="text/css"media="screen"><link rel="stylesheet"href="https://www.gtk.org/assets/css/colorful.css"type="text/css"media="screen"><link rel="stylesheet"href="https://www.gtk.org/assets/css/index.css"type="text/css"media="screen"></head><body><header class="navbar small bg-dark"><nav class="container navbar-expand-md px-0 px-md-3"><a href="https://www.gtk.org"class="navbar-brand text-white"><img src="https://www.gtk.org/assets/img/logo-gtk-sm.png"class="pr-2"style="max-width:40px;"><strong>GTK</strong></a> <a class="btn navbar-toggler border-0 bg-white"role="button"data-toggle="collapse"data-target="#navbarSupportedContent"href="#"><i class="fas fa-ellipsis-h text-dark"></i></a><div class="collapse navbar-collapse"id="navbarSupportedContent"><ul class="navbar-nav ml-auto"><a href="https://www.gtk.org/features/"class="nav-link-dark float-right text-white rounded">Features</a> <a href="https://www.gtk.org/docs/"class="nav-link-dark float-right text-white rounded">Docs</a> <a href="https://www.gtk.org/community/"class="nav-link-dark float-right text-white rounded">Community</a> <a href="https://gitlab.gnome.org/GNOME/gtk/"target="_blank"class="nav-link-dark float-right text-white rounded">Code</a> <a href="https://blog.gtk.org/"target="_blank"class="nav-link-dark float-right text-white rounded">Development Blog</a></ul></div></nav></header><button class="d-none btn border border-info bg-white rounded-circle position-fixed"id="btn-go-to-top"><i class="fas fa-angle-up"></i></button><section class="py-4 d-flex flex-column align-items-center bg-dark text-white"><div class="container"><div class="row align-items-center"><div class="col-lg-6 d-flex justify-content-end flex-column main-heading"><h1 class="display-4 pb-3">Create apps that users just love</h1><span class="text-info mb-4 lead"><p>Offering a complete set of UI elements, GTK is suitable for projects ranging from small one-off tools to complete application suites.</p></span><div class="mb-4 d-flex"><a href="https://www.gtk.org/docs/"class="btn btn-md btn-primary"role="button">Learn GTK</a><div class="dropdown"><a class="btn btn-md btn-outline-secondary dropdown-toggle ml-2"href="#"role="button"id="dropdownMenuLink"data-toggle="dropdown"aria-haspopup="true"aria-expanded="false">Downloads</a><div class="dropdown-menu"aria-labelledby="dropdownMenuLink"><a href="https://www.gtk.org/docs/installations/linux/"class="dropdown-item"><i class="fab fa-linux pr-2 fa-fw"></i>Linux</a> <a href="https://www.gtk.org/docs/installations/windows/"class="dropdown-item"><i class="fab fa-windows pr-2 fa-fw"></i>Windows</a> <a href="https://www.gtk.org/docs/installations/macos/"class="dropdown-item"><i class="fab fa-apple pr-2 fa-fw"></i>MacOS</a></div></div></div><div><span class="text-light"><span class="small text-info">Latest stable</span> 4.16.7</span><br><span class="text-light"><span class="small text-info">Latest unstable</span> 4.17.0</span><br><span class="text-light"><span class="small text-info">Latest old stable</span> 3.24.43</span><br></div></div><div class="col-lg-6 d-flex justify-content-center align-items-center"><img src="https://www.gtk.org/assets/img/wall-gtk4.svg"class="img-fluid pl-lg-5"alt="GTK Community Wallpaper"></div></div></div></section><section class="pt-5 pb-4"id="bindings"><div class="container"><div class="row text-center d-flex justify-content-center"><div class="col-md-10 col-lg-7"><h2 class="font-weight-light mb-3">Work with the language of your choice</h2><span class="text-muted"><p>Develop your GTK app with your language of choice by using Language Bindings or wrappers and take full advantage of the official GNOME bindings which guarantee API stability and time-based releases.</p></span></div></div><div class="row d-flex flex-column align-items-center py-4 px-3"><div class="col-lg-8 p-0 rounded-top overflow-hidden"><div class="list-group flex-row flex-wrap bg-dark"id="list-tab"role="tablist"><a class="col grp-btn btn py-1 px-1 small border-0 rounded-0 active text-light"id="list-c-list"data-toggle="list"href="#list-c"role="tab"aria-controls="c"aria-selected="true">C</a> <a class="col grp-btn btn py-1 px-1 small border-0 rounded-0 text-light"id="list-javascript-list"data-toggle="list"href="#list-javascript"role="tab"aria-controls="javascript"aria-selected="false">JavaScript</a> <a class="col grp-btn btn py-1 px-1 small border-0 rounded-0 text-light"id="list-pl-list"data-toggle="list"href="#list-pl"role="tab"aria-controls="pl"aria-selected="false">Perl</a> <a class="col grp-btn btn py-1 px-1 small border-0 rounded-0 text-light"id="list-py-list"data-toggle="list"href="#list-py"role="tab"aria-controls="py"aria-selected="false">Python</a> <a class="col grp-btn btn py-1 px-1 small border-0 rounded-0 text-light"id="list-rs-list"data-toggle="list"href="#list-rs"role="tab"aria-controls="rs"aria-selected="false">Rust</a> <a class="col grp-btn btn py-1 px-1 small border-0 rounded-0 text-light"id="list-vala-list"data-toggle="list"href="#list-vala"role="tab"aria-controls="vala"aria-selected="false">Vala</a></div></div><div class="col-lg-8 p-0 bg-light border border-info border-top-0 pl-3 overflow-auto"><div class="tab-content"id="nav-tabContent"><div class="tab-pane overflow-y-auto fade small pt-3 active show"id="list-c"role="tabpanel"aria-labelledby="list-c-list"><div class="language-cpp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// Include gtk</span> <span class="cp">#include <gtk/gtk.h> </span> <span class="k">static</span> <span class="kt">void</span> <span class="nf">on_activate</span> <span class="p">(</span><span class="n">GtkApplication</span> <span class="o">*</span><span class="n">app</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Create a new window</span> <span class="n">GtkWidget</span> <span class="o">*</span><span class="n">window</span> <span class="o">=</span> <span class="n">gtk_application_window_new</span> <span class="p">(</span><span class="n">app</span><span class="p">);</span> <span class="c1">// Create a new button</span> <span class="n">GtkWidget</span> <span class="o">*</span><span class="n">button</span> <span class="o">=</span> <span class="n">gtk_button_new_with_label</span> <span class="p">(</span><span class="s">"Hello, World!"</span><span class="p">);</span> <span class="c1">// When the button is clicked, close the window passed as an argument</span> <span class="n">g_signal_connect_swapped</span> <span class="p">(</span><span class="n">button</span><span class="p">,</span> <span class="s">"clicked"</span><span class="p">,</span> <span class="n">G_CALLBACK</span> <span class="p">(</span><span class="n">gtk_window_close</span><span class="p">),</span> <span class="n">window</span><span class="p">);</span> <span class="n">gtk_window_set_child</span> <span class="p">(</span><span class="n">GTK_WINDOW</span> <span class="p">(</span><span class="n">window</span><span class="p">),</span> <span class="n">button</span><span class="p">);</span> <span class="n">gtk_window_present</span> <span class="p">(</span><span class="n">GTK_WINDOW</span> <span class="p">(</span><span class="n">window</span><span class="p">));</span> <span class="p">}</span> <span class="kt">int</span> <span class="nf">main</span> <span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">argv</span><span class="p">[])</span> <span class="p">{</span> <span class="c1">// Create a new application</span> <span class="n">GtkApplication</span> <span class="o">*</span><span class="n">app</span> <span class="o">=</span> <span class="n">gtk_application_new</span> <span class="p">(</span><span class="s">"com.example.GtkApplication"</span><span class="p">,</span> <span class="n">G_APPLICATION_FLAGS_NONE</span><span class="p">);</span> <span class="n">g_signal_connect</span> <span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="s">"activate"</span><span class="p">,</span> <span class="n">G_CALLBACK</span> <span class="p">(</span><span class="n">on_activate</span><span class="p">),</span> <span class="nb">NULL</span><span class="p">);</span> <span class="k">return</span> <span class="n">g_application_run</span> <span class="p">(</span><span class="n">G_APPLICATION</span> <span class="p">(</span><span class="n">app</span><span class="p">),</span> <span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">);</span> <span class="p">}</span> </code></pre></div></div></div><div class="tab-pane overflow-auto fade small pt-3"id="list-javascript"role="tabpanel"aria-labelledby="list-javascript-list"><div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">imports</span><span class="p">.</span><span class="nx">gi</span><span class="p">.</span><span class="nx">versions</span><span class="p">[</span><span class="dl">'</span><span class="s1">Gtk</span><span class="dl">'</span><span class="p">]</span> <span class="o">=</span> <span class="dl">'</span><span class="s1">4.0</span><span class="dl">'</span><span class="p">;</span> <span class="kd">const</span> <span class="nx">Gtk</span> <span class="o">=</span> <span class="nx">imports</span><span class="p">.</span><span class="nx">gi</span><span class="p">.</span><span class="nx">Gtk</span><span class="p">;</span> <span class="c1">// Create a new application</span> <span class="kd">let</span> <span class="nx">app</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Gtk</span><span class="p">.</span><span class="nx">Application</span><span class="p">({</span> <span class="na">application_id</span><span class="p">:</span> <span class="dl">'</span><span class="s1">com.example.GtkApplication</span><span class="dl">'</span> <span class="p">});</span> <span class="c1">// When the application is launched…</span> <span class="nx">app</span><span class="p">.</span><span class="nx">connect</span><span class="p">(</span><span class="dl">'</span><span class="s1">activate</span><span class="dl">'</span><span class="p">,</span> <span class="p">()</span> <span class="o">=></span> <span class="p">{</span> <span class="c1">// … create a new window …</span> <span class="kd">let</span> <span class="nx">win</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Gtk</span><span class="p">.</span><span class="nx">ApplicationWindow</span><span class="p">({</span> <span class="na">application</span><span class="p">:</span> <span class="nx">app</span> <span class="p">});</span> <span class="c1">// … with a button in it …</span> <span class="kd">let</span> <span class="nx">btn</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Gtk</span><span class="p">.</span><span class="nx">Button</span><span class="p">({</span> <span class="na">label</span><span class="p">:</span> <span class="dl">'</span><span class="s1">Hello, World!</span><span class="dl">'</span> <span class="p">});</span> <span class="c1">// … which closes the window when clicked</span> <span class="nx">btn</span><span class="p">.</span><span class="nx">connect</span><span class="p">(</span><span class="dl">'</span><span class="s1">clicked</span><span class="dl">'</span><span class="p">,</span> <span class="p">()</span> <span class="o">=></span> <span class="p">{</span> <span class="nx">win</span><span class="p">.</span><span class="nx">close</span><span class="p">();</span> <span class="p">});</span> <span class="nx">win</span><span class="p">.</span><span class="nx">set_child</span><span class="p">(</span><span class="nx">btn</span><span class="p">);</span> <span class="nx">win</span><span class="p">.</span><span class="nx">present</span><span class="p">();</span> <span class="p">});</span> <span class="c1">// Run the application</span> <span class="nx">app</span><span class="p">.</span><span class="nx">run</span><span class="p">([]);</span> </code></pre></div></div></div><div class="tab-pane overflow-auto fade small pt-3"id="list-pl"role="tabpanel"aria-labelledby="list-pl-list"><div class="language-perl highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#!/usr/bin/env perl</span> <span class="k">use</span> <span class="nv">strict</span><span class="p">;</span> <span class="k">use</span> <span class="nv">warnings</span><span class="p">;</span> <span class="k">use</span> <span class="nv">utf8</span><span class="p">;</span> <span class="k">use</span> <span class="nn">Glib::</span><span class="nv">IO</span><span class="p">;</span> <span class="k">use</span> <span class="nv">Gtk4</span><span class="p">;</span> <span class="c1"># Create a new application</span> <span class="k">my</span> <span class="nv">$app</span> <span class="o">=</span> <span class="nn">Gtk3::</span><span class="nv">Application</span><span class="o">-></span><span class="k">new</span><span class="p">('</span><span class="s1">com.example.Gtk3Application</span><span class="p">',</span> <span class="p">'</span><span class="s1">G_APPLICATION_FLAGS_NONE</span><span class="p">');</span> <span class="c1"># When the application is launched…</span> <span class="nv">$app</span><span class="o">-></span><span class="nv">signal_connect</span><span class="p">(</span> <span class="s">activate</span> <span class="o">=></span> <span class="k">sub </span><span class="p">{</span> <span class="k">my</span> <span class="nv">$app</span> <span class="o">=</span> <span class="nb">shift</span><span class="p">;</span> <span class="c1"># … create a new window …</span> <span class="k">my</span> <span class="nv">$win</span> <span class="o">=</span> <span class="nn">Gtk3::</span><span class="nv">ApplicationWindow</span><span class="o">-></span><span class="k">new</span><span class="p">(</span><span class="nv">$app</span><span class="p">);</span> <span class="c1"># … with a button in it …</span> <span class="k">my</span> <span class="nv">$btn</span> <span class="o">=</span> <span class="nn">Gtk3::</span><span class="nv">Button</span><span class="o">-></span><span class="k">new</span><span class="p">('</span><span class="s1">Hello World!</span><span class="p">');</span> <span class="c1"># … which closes the window when clicked</span> <span class="nv">$btn</span><span class="o">-></span><span class="nv">signal_connect</span><span class="p">(</span><span class="s">clicked</span> <span class="o">=></span> <span class="k">sub </span><span class="p">{</span> <span class="nv">$win</span><span class="o">-></span><span class="nb">close</span><span class="p">();</span> <span class="p">});</span> <span class="nv">$win</span><span class="o">-></span><span class="nv">set_child</span><span class="p">(</span><span class="nv">$btn</span><span class="p">);</span> <span class="nv">$win</span><span class="o">-></span><span class="nv">present</span><span class="p">();</span> <span class="p">}</span> <span class="p">);</span> <span class="c1"># Run the application</span> <span class="nv">$app</span><span class="o">-></span><span class="nv">run</span><span class="p">(</span><span class="o">\</span><span class="nv">@ARGV</span><span class="p">);</span> </code></pre></div></div></div><div class="tab-pane overflow-auto fade small pt-3"id="list-py"role="tabpanel"aria-labelledby="list-py-list"><div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Load Gtk </span><span class="kn">import</span> <span class="nn">gi</span> <span class="n">gi</span><span class="p">.</span><span class="n">require_version</span><span class="p">(</span><span class="s">'Gtk'</span><span class="p">,</span> <span class="s">'4.0'</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">gi.repository</span> <span class="kn">import</span> <span class="n">Gtk</span> <span class="c1"># When the application is launched… </span><span class="k">def</span> <span class="nf">on_activate</span><span class="p">(</span><span class="n">app</span><span class="p">):</span> <span class="c1"># … create a new window… </span> <span class="n">win</span> <span class="o">=</span> <span class="n">Gtk</span><span class="p">.</span><span class="n">ApplicationWindow</span><span class="p">(</span><span class="n">application</span><span class="o">=</span><span class="n">app</span><span class="p">)</span> <span class="c1"># … with a button in it… </span> <span class="n">btn</span> <span class="o">=</span> <span class="n">Gtk</span><span class="p">.</span><span class="n">Button</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="s">'Hello, World!'</span><span class="p">)</span> <span class="c1"># … which closes the window when clicked </span> <span class="n">btn</span><span class="p">.</span><span class="n">connect</span><span class="p">(</span><span class="s">'clicked'</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">win</span><span class="p">.</span><span class="n">close</span><span class="p">())</span> <span class="n">win</span><span class="p">.</span><span class="n">set_child</span><span class="p">(</span><span class="n">btn</span><span class="p">)</span> <span class="n">win</span><span class="p">.</span><span class="n">present</span><span class="p">()</span> <span class="c1"># Create a new application </span><span class="n">app</span> <span class="o">=</span> <span class="n">Gtk</span><span class="p">.</span><span class="n">Application</span><span class="p">(</span><span class="n">application_id</span><span class="o">=</span><span class="s">'com.example.GtkApplication'</span><span class="p">)</span> <span class="n">app</span><span class="p">.</span><span class="n">connect</span><span class="p">(</span><span class="s">'activate'</span><span class="p">,</span> <span class="n">on_activate</span><span class="p">)</span> <span class="c1"># Run the application </span><span class="n">app</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span> </code></pre></div></div></div><div class="tab-pane overflow-auto fade small pt-3"id="list-rs"role="tabpanel"aria-labelledby="list-rs-list"><div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">use</span> <span class="nn">glib</span><span class="p">::</span><span class="n">clone</span><span class="p">;</span> <span class="c">// glib and other dependencies are re-exported by the gtk crate</span> <span class="k">use</span> <span class="nn">gtk</span><span class="p">::</span><span class="n">glib</span><span class="p">;</span> <span class="k">use</span> <span class="nn">gtk</span><span class="p">::</span><span class="nn">prelude</span><span class="p">::</span><span class="o">*</span><span class="p">;</span> <span class="c">// When the application is launched…</span> <span class="k">fn</span> <span class="nf">on_activate</span><span class="p">(</span><span class="n">application</span><span class="p">:</span> <span class="o">&</span><span class="nn">gtk</span><span class="p">::</span><span class="n">Application</span><span class="p">)</span> <span class="p">{</span> <span class="c">// … create a new window …</span> <span class="k">let</span> <span class="n">window</span> <span class="o">=</span> <span class="nn">gtk</span><span class="p">::</span><span class="nn">ApplicationWindow</span><span class="p">::</span><span class="nf">new</span><span class="p">(</span><span class="n">application</span><span class="p">);</span> <span class="c">// … with a button in it …</span> <span class="k">let</span> <span class="n">button</span> <span class="o">=</span> <span class="nn">gtk</span><span class="p">::</span><span class="nn">Button</span><span class="p">::</span><span class="nf">with_label</span><span class="p">(</span><span class="s">"Hello World!"</span><span class="p">);</span> <span class="c">// … which closes the window when clicked</span> <span class="n">button</span><span class="nf">.connect_clicked</span><span class="p">(</span><span class="nd">clone!</span><span class="p">(</span><span class="o">@</span><span class="n">weak</span> <span class="n">window</span> <span class="k">=></span> <span class="k">move</span> <span class="p">|</span><span class="mi">_</span><span class="p">|</span> <span class="n">window</span><span class="nf">.close</span><span class="p">()));</span> <span class="n">window</span><span class="nf">.set_child</span><span class="p">(</span><span class="nf">Some</span><span class="p">(</span><span class="o">&</span><span class="n">button</span><span class="p">));</span> <span class="n">window</span><span class="nf">.present</span><span class="p">();</span> <span class="p">}</span> <span class="k">fn</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="c">// Create a new application with the builder pattern</span> <span class="k">let</span> <span class="n">app</span> <span class="o">=</span> <span class="nn">gtk</span><span class="p">::</span><span class="nn">Application</span><span class="p">::</span><span class="nf">builder</span><span class="p">()</span> <span class="nf">.application_id</span><span class="p">(</span><span class="s">"com.github.gtk-rs.examples.basic"</span><span class="p">)</span> <span class="nf">.build</span><span class="p">();</span> <span class="n">app</span><span class="nf">.connect_activate</span><span class="p">(</span><span class="n">on_activate</span><span class="p">);</span> <span class="c">// Run the application</span> <span class="n">app</span><span class="nf">.run</span><span class="p">();</span> <span class="p">}</span> </code></pre></div></div></div><div class="tab-pane overflow-auto fade small pt-3"id="list-vala"role="tabpanel"aria-labelledby="list-vala-list"><div class="language-vala highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kt">int</span> <span class="nf">main</span> <span class="p">(</span><span class="kt">string</span><span class="p">[]</span> <span class="n">argv</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Create a new application</span> <span class="k">var</span> <span class="n">app</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Gtk</span><span class="p">.</span><span class="nf">Application</span> <span class="p">(</span><span class="s">"com.example.GtkApplication"</span><span class="p">,</span> <span class="n">GLib</span><span class="p">.</span><span class="n">ApplicationFlags</span><span class="p">.</span><span class="n">FLAGS_NONE</span><span class="p">);</span> <span class="n">app</span><span class="p">.</span><span class="n">activate</span><span class="p">.</span><span class="nf">connect</span> <span class="p">(()</span> <span class="p">=></span> <span class="p">{</span> <span class="c1">// Create a new window</span> <span class="k">var</span> <span class="n">window</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Gtk</span><span class="p">.</span><span class="nf">ApplicationWindow</span> <span class="p">(</span><span class="n">app</span><span class="p">);</span> <span class="c1">// Create a new button</span> <span class="k">var</span> <span class="n">button</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Gtk</span><span class="p">.</span><span class="n">Button</span><span class="p">.</span><span class="nf">with_label</span> <span class="p">(</span><span class="s">"Hello, World!"</span><span class="p">);</span> <span class="c1">// When the button is clicked, close the window</span> <span class="n">button</span><span class="p">.</span><span class="n">clicked</span><span class="p">.</span><span class="nf">connect</span> <span class="p">(()</span> <span class="p">=></span> <span class="p">{</span> <span class="n">window</span><span class="p">.</span><span class="nf">close</span> <span class="p">();</span> <span class="p">});</span> <span class="n">window</span><span class="p">.</span><span class="nf">set_child</span> <span class="p">(</span><span class="n">button</span><span class="p">);</span> <span class="n">window</span><span class="p">.</span><span class="nf">present</span> <span class="p">();</span> <span class="p">});</span> <span class="k">return</span> <span class="n">app</span><span class="p">.</span><span class="nf">run</span> <span class="p">(</span><span class="n">argv</span><span class="p">);</span> <span class="p">}</span> </code></pre></div></div></div></div></div></div></div></section><section class="py-4"style="background: linear-gradient(var(--light), var(--white));"><div class="container py-3"><div class="row text-center d-flex justify-content-center"><div class="col-md-10 col-lg-7"><h2 class="font-weight-light mb-3">Apps built with GTK</h2><span class="text-muted"><p>Developers around the world have used GTK as a platform to create apps that solve problems faced by end-users.</p></span></div></div><div class="app-logos slider pt-4 pb-5"><div class="slide d-flex flex-column align-items-center text-center"><a href="https://gimp.org"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-gimp.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="GIMP"></a><span class="text-muted small">GIMP</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://flathub.org/apps/details/org.gnome.font-viewer"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-fonts.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Fonts"></a><span class="text-muted small">Fonts</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://wiki.gnome.org/Apps/Calculator"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-calculator.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Calculator"></a><span class="text-muted small">Calculator</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://wiki.gnome.org/Apps/Dictionary"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-dictionary.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Dictionary"></a><span class="text-muted small">Dictionary</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://wiki.gnome.org/Apps/Games"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-games.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Games"></a><span class="text-muted small">Games</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://wiki.gnome.org/Apps/Evolution"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-evolution.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Evolution"></a><span class="text-muted small">Evolution</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://wiki.gnome.org/Apps/EyeOfGnome"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-image-viewer.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Image Viewer"></a><span class="text-muted small">Image Viewer</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://wiki.gnome.org/Apps/Polari"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-polari.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Polari"></a><span class="text-muted small">Polari</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://wiki.gnome.org/Apps/Keysign"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-key-sign.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Key Sign"></a><span class="text-muted small">Key Sign</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://wiki.gnome.org/Apps/Maps"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-maps.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Maps"></a><span class="text-muted small">Maps</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://transmissionbt.com/"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-transmission.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Transmission"></a><span class="text-muted small">Transmission</span></div><div class="slide d-flex flex-column align-items-center text-center"><a href="https://gitlab.gnome.org/World/PasswordSafe"target="_blank"><img src="https://www.gtk.org/assets/img/apps/app-password-safe.png"class="img-fluid app-icon icon-dropshadow mb-2"alt="Password Safe"></a><span class="text-muted small">Password Safe</span></div></div></div></section><section class="pt-3 pb-4"id="features"><div class="container"><div class="row text-center d-flex justify-content-center"><div class="col-md-10 col-lg-7"><h2 class="font-weight-light mb-3">A feature-rich development tool</h2><span class="text-muted"><p>GTK has all the features that a widget toolkit needs to have. These features make it the most trusted toolkit for developing Linux applications.</p></span></div></div><div class="row feature-holder pt-5"><div class="col-md-6 px-3"><div class="col d-flex px-0 px-sm-3 pb-4"><div class="pr-2"><span class="fa-stack fa-1x fa-fw d-flex justify-content-center align-items-center"><i class="fas fa-circle fa-stack-2x fa-fw text-secondary text-center"></i> <i class="fas fa-door-open fa-stack-1x fa-inverse fa-fw text-center"></i></span></div><div><h6 class="mb-1">Portability</h6><span class="text-muted small"><p>Projects built using GTK and its dependencies run on well known operating systems.</p></span></div></div></div><div class="col-md-6 px-3"><div class="col d-flex px-0 px-sm-3 pb-4"><div class="pr-2"><span class="fa-stack fa-1x fa-fw d-flex justify-content-center align-items-center"><i class="fas fa-circle fa-stack-2x fa-fw text-secondary text-center"></i> <i class="fas fa-balance-scale fa-stack-1x fa-inverse fa-fw text-center"></i></span></div><div><h6 class="mb-1">Stability</h6><span class="text-muted small"><p>GTK delivers the enticing features and superb performance which adds to your applications.</p></span></div></div></div><div class="col-md-6 px-3"><div class="col d-flex px-0 px-sm-3 pb-4"><div class="pr-2"><span class="fa-stack fa-1x fa-fw d-flex justify-content-center align-items-center"><i class="fas fa-circle fa-stack-2x fa-fw text-secondary text-center"></i> <i class="fas fa-random fa-stack-1x fa-inverse fa-fw text-center"></i></span></div><div><h6 class="mb-1">Language Bindings</h6><span class="text-muted small"><p>GTK is written in C but has been designed to support a wide range of languages such as Python, JavaScript, C++, Rust and <a href="/docs/language-bindings/">many more</a>.</p></span></div></div></div><div class="col-md-6 px-3"><div class="col d-flex px-0 px-sm-3 pb-4"><div class="pr-2"><span class="fa-stack fa-1x fa-fw d-flex justify-content-center align-items-center"><i class="fas fa-circle fa-stack-2x fa-fw text-secondary text-center"></i> <i class="fas fa-cubes fa-stack-1x fa-inverse fa-fw text-center"></i></span></div><div><h6 class="mb-1">Interfaces</h6><span class="text-muted small"><p>GTK has a comprehensive collection of core widgets like Buttons, Windows, Toolbars for use in your application.</p></span></div></div></div><div class="col-md-6 px-3"><div class="col d-flex px-0 px-sm-3 pb-4"><div class="pr-2"><span class="fa-stack fa-1x fa-fw d-flex justify-content-center align-items-center"><i class="fas fa-circle fa-stack-2x fa-fw text-secondary text-center"></i> <i class="fas fa-code-branch fa-stack-1x fa-inverse fa-fw text-center"></i></span></div><div><h6 class="mb-1">Open Source</h6><span class="text-muted small"><p>GTK is a free and open-source project maintained by GNOME and an active community of contributors. GTK is released under the terms of the <a href="https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">GNU Lesser General Public License</a>.</p></span></div></div></div><div class="col-md-6 px-3"><div class="col d-flex px-0 px-sm-3 pb-4"><div class="pr-2"><span class="fa-stack fa-1x fa-fw d-flex justify-content-center align-items-center"><i class="fas fa-circle fa-stack-2x fa-fw text-secondary text-center"></i> <i class="fas fa-code fa-stack-1x fa-inverse fa-fw text-center"></i></span></div><div><h6 class="mb-1">API</h6><span class="text-muted small"><p>GTK boasts of an easy to use <a href="/docs/apis/">API</a> which helps in decreasing your development time and help you achieve better results.</p></span></div></div></div><div class="col-md-6 px-3"><div class="col d-flex px-0 px-sm-3 pb-4"><div class="pr-2"><span class="fa-stack fa-1x fa-fw d-flex justify-content-center align-items-center"><i class="fas fa-circle fa-stack-2x fa-fw text-secondary text-center"></i> <i class="fas fa-suitcase-rolling fa-stack-1x fa-inverse fa-fw text-center"></i></span></div><div><h6 class="mb-1">Accommodation</h6><span class="text-muted small"><p>GTK caters to many features like Native look and feel, theme support, Object-oriented approach that today’s developers look for in a toolkit.</p></span></div></div></div><div class="col-md-6 px-3"><div class="col d-flex px-0 px-sm-3 pb-4"><div class="pr-2"><span class="fa-stack fa-1x fa-fw d-flex justify-content-center align-items-center"><i class="fas fa-circle fa-stack-2x fa-fw text-secondary text-center"></i> <i class="fas fa-layer-group fa-stack-1x fa-inverse fa-fw text-center"></i></span></div><div><h6 class="mb-1">Foundations</h6><span class="text-muted small"><p>GTK is built on top of GLib. GLib provides the fundamental data types and system integration points to avoid duplicated code in applications.</p></span></div></div></div></div></div></section><section class="py-4"id="development"style="background: linear-gradient(var(--light), var(--white));"><div class="container"><div class="row py-4"><div class="col-md-4 py-3 py-md-0 px-0 px-md-3"><div class="w-100 h-100 bg-white py-4 px-3 mb-2 border rounded card shadow"><div class="mb-2 d-flex justify-content-between"><h5 class="ml-2 my-auto font-weight-normal">Develop with GTK</h5><span class="mx-3 my-auto"><i class="fas fa-toolbox fa-fw fa-lg my-auto"></i></span></div><span class="pt-2 px-2 text-muted small text-justify"><p>By taking advantage of GTK being a cross-platform development tool and its easy to use API, you can develop amazing apps using the GTK. If you are interested in developing an app, get started now by developing this <a href="https://docs.gtk.org/gtk4/getting_started.html">example application</a>.</p></span></div></div><div class="col-md-4 py-3 py-md-0 px-0 px-md-3"><div class="w-100 h-100 bg-white py-4 px-3 mb-2 border rounded card shadow"><div class="mb-2 d-flex justify-content-between"><h5 class="ml-2 my-auto font-weight-normal">Develop GTK</h5><span class="mx-3 my-auto"><i class="fas fa-cogs fa-fw fa-lg my-auto"></i></span></div><span class="pt-2 px-2 text-muted small text-justify"><p>GTK is a large project and relies on volunteers from around the world. To help us with the project development, hack away on the existing <a href="https://gitlab.gnome.org/GNOME/gtk/issues/">bugs and feature requests</a>.</p></span></div></div><div class="col-md-4 py-3 py-md-0 px-0 px-md-3"><div class="w-100 h-100 bg-white py-4 px-3 mb-2 border rounded card shadow"><div class="mb-2 d-flex justify-content-between"><h5 class="ml-2 my-auto font-weight-normal">Looking for Help?</h5><span class="mx-3 my-auto"><i class="fas fa-question-circle fa-fw fa-lg my-auto"></i></span></div><span class="pt-2 px-2 text-muted small text-justify"><p>If you want to ask questions about GTK, whether it’s for developing applications with GTK or contributing to GTK itself, you can use the GNOME <a href="https://discourse.gnome.org">Discourse</a> instance, under the <a href="https://discourse.gnome.org/c/platform/core">Platform/Core</a> category. You can use tags like <em>gtk</em> or <em>glib</em> to narrow down the topic of discussion to specific libraries. You can also ask questions in our <a href="https://matrix.to/#/#gtk:gnome.org">Matrix</a> room.</p></span></div></div></div></div></section><section class="py-4"id="events"style="background: url('https://www.gtk.org/assets/img/wall-events-pattern.svg')"><div class="container"><h2 class="text-center font-weight-light mb-3">News and Events</h2><div class="row py-4"><div class="col-md-4 px-3 pb-4 pb-md-0"><div class="w-100 px-4 py-4 rounded shadow bg-light h-100"><h5 class="border-bottom border-primary pb-2 font-weight-normal">Catch up with GTK development</h5><span class="text-muted small"><p>Get in touch with GTK developers through <a href="https://matrix.to/#/#gtk:gnome.org">Matrix</a>. Get updates about GTK and its community from <a href="https://blog.gtk.org/">GTK blog</a> or on <a href="https://floss.social/@GTK">Mastodon</a>.</p></span></div></div><div class="col-md-4 px-3 pb-4 pb-md-0"><div class="w-100 px-4 py-4 rounded shadow bg-light h-100"><h5 class="border-bottom border-primary pb-2 font-weight-normal">Meet the community</h5><span class="text-muted small"><p>As regularly as possible, GTK team meetings take place at <a href="https://guadec.org">conferences</a> and <a href="https://wiki.gnome.org/Hackfests">hackfests</a> to discuss the future of GTK and define a <a href="https://wiki.gnome.org/Projects/GTK/Roadmap">roadmap</a>.</p></span></div></div><div class="col-md-4 px-3 pb-4 pb-md-0"><div class="w-100 px-4 py-4 rounded shadow bg-light h-100"><h5 class="border-bottom border-primary pb-2 font-weight-normal">Contribute to GTK</h5><span class="text-muted small"><p>If you are a developer and want to contribute to GTK, you are more than <a href="/docs/getting-started/">welcome to do so</a>.</p></span></div></div></div></div></section><script src="https://www.gtk.org/assets/jquery/dist/jquery.min.js"></script><script src="https://www.gtk.org/assets/popper.js/dist/umd/popper.min.js"></script><script src="https://www.gtk.org/assets/bootstrap/dist/js/bootstrap.min.js"></script><script>var btnTop = $("#btn-go-to-top"); $(window).scroll(function() { if ($(window).scrollTop() < 400) { btnTop.addClass("d-none"); } else { btnTop.removeClass("d-none"); } }); btnTop.on("click", function(e) { e.preventDefault(); $("html, body").animate({scrollTop: 0}); });</script><script src="https://www.gtk.org/assets/slick-carousel/slick/slick.min.js"></script><script>// controls the appearance of code container for language bindings var tabs = document.querySelectorAll(".tab-pane"); var i, l = tabs.length; var max = 360; for (i = 0; i < l; i++) { tabs[i].style.height = max + "px"; } // controls the app silder $(document).ready(function(){ $('.app-logos').slick({ slidesToShow: 6, swipeToSlide: true, autoplay: true, autoplaySpeed: 2000, arrows: false, dots: false, pauseOnHover: false, responsive: [ { breakpoint: 992, settings: { slidesToShow: 4, autoplaySpeed: 1500 } }, { breakpoint: 768, settings: { slidesToShow: 2, autoplaySpeed: 1000 } }] }); }); // used to implement the bootstrap dropdown $(".dropdown-toggle").dropdown();</script><footer class="container-fluid bg-dark navbar-dark text-info py-4 small"><div class="container"><div class="row"><div class="col-sm-5 col-lg-4 py-3 py-sm-2"><a href="https://www.gnome.org/"><img src="https://www.gtk.org/assets/img/logo-gnome-horizontal.svg"class="img-fluid pb-2"width="100"></a><p>GTK is hosted by GNOME.</p><p>GTK is maintained by the <a href="https://www.gtk.org/community#contributors"class="text-muted font-weight-bold">GTK Team</a>.</p><p>© 1997-2024, The GTK Team. All Rights Reserved.</p><p>GTK and the GTK logo are <a href="https://foundation.gnome.org/legal-and-trademarks/"class="text-muted font-weight-bold">trademarks of the GNOME Foundation</a>.</p></div><div class="col-sm-7 col-lg-5 py-3 py-sm-2"><div class="d-flex"><div class="col pl-0"><h6 class="text-muted">PROJECT</h6><ul class="list-unstyled text-small"><li><a href="https://www.gtk.org/"class="text-info">GTK</a></li><li><a href="https://www.gtk.org/features/"class="text-info">Features</a></li><li><a href="https://www.gtk.org/docs/"class="text-info">Docs</a></li><li><a href="https://download.gnome.org/sources/gtk/"class="text-info">Downloads</a></li><li><a href="https://gitlab.gnome.org/GNOME/gtk/tree/master/COPYING"class="text-info">License</a></li><li><a href="https://gitlab.gnome.org/GNOME/gtk/-/releases"class="text-info">Releases</a></li><li><a href="https://gitlab.gnome.org/GNOME/gtk/"class="text-info">Code</a></li></ul></div><div class="col pl-0"><h6 class="text-muted">SUPPORT</h6><ul class="list-unstyled text-small"><li><a href="https://docs.gtk.org/gtk4/question_index.html"class="text-info">FAQs</a></li><li><a href="https://gitlab.gnome.org/GNOME/gtk/issues/new"class="text-info">Report a Bug</a></li><li><a href="https://gitlab.gnome.org/GNOME/gtk/issues/new"class="text-info">Request a feature</a></li></ul></div><div class="col pl-0"><h6 class="text-muted">COMMUNITY</h6><ul class="list-unstyled text-small"><li><a href="https://www.gtk.org/community/"class="text-info">Community</a></li><li><a href="https://blog.gtk.org/"class="text-info">Development Blog</a></li><li><a href="https://discourse.gnome.org"class="text-info">Discussion</a></li><li><a href="https://conduct.gnome.org"class="text-info">Code of Conduct</a></li><li><a href="http://www.gnome.org/foundation/"class="text-info">Donate</a></li></ul></div></div></div><div class="col-sm-12 col-lg-3 py-3 py-sm-2"><h5>About the Site</h5><ul class="list-unstyled text-small"><li>Hosted on <a href="https://gitlab.gnome.org/Teams/Websites/www.gtk.org"class="text-muted font-weight-bold">Gitlab</a>.</li><li>Powered by <a href="https://jekyllrb.com/"class="text-muted font-weight-bold">Jekyll</a>.</li><li>Report <a href="https://gitlab.gnome.org/Teams/Websites/www.gtk.org/-/issues/new"class="text-muted font-weight-bold">an issue</a>.</li></ul><ul class="list-unstyled list-inline text-small"><li class="list-inline-item"><a href="https://gitlab.gnome.org/GNOME/gtk/"rel="me"class="text-muted text-primary"><i class="fab fa-gitlab"></i></a></li><li class="list-inline-item"><a href="https://discourse.gnome.org/c/platform/core/"rel="me"class="text-muted text-primary"><i class="fab fa-discourse"></i></a></li><li class="list-inline-item"><a href="https://floss.social/@GTK"rel="me"class="text-muted text-primary"><i class="fab fa-mastodon"></i></a></li></ul></div></div></div></footer></body></html>