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.
// Include gtk#include <gtk/gtk.h>staticvoidon_activate(GtkApplication*app){// Create a new windowGtkWidget*window=gtk_application_window_new(app);// Create a new buttonGtkWidget*button=gtk_button_new_with_label("Hello, World!");// When the button is clicked, close the window passed as an argumentg_signal_connect_swapped(button,"clicked",G_CALLBACK(gtk_window_close),window);gtk_window_set_child(GTK_WINDOW(window),button);gtk_window_present(GTK_WINDOW(window));}intmain(intargc,char*argv[]){// Create a new applicationGtkApplication*app=gtk_application_new("com.example.GtkApplication",G_APPLICATION_FLAGS_NONE);g_signal_connect(app,"activate",G_CALLBACK(on_activate),NULL);returng_application_run(G_APPLICATION(app),argc,argv);}
imports.gi.versions['Gtk']='4.0';constGtk=imports.gi.Gtk;// Create a new applicationletapp=newGtk.Application({application_id:'com.example.GtkApplication'});// When the application is launched…app.connect('activate',()=>{// … create a new window …letwin=newGtk.ApplicationWindow({application:app});// … with a button in it …letbtn=newGtk.Button({label:'Hello, World!'});// … which closes the window when clickedbtn.connect('clicked',()=>{win.close();});win.set_child(btn);win.present();});// Run the applicationapp.run([]);
#!/usr/bin/env perlusestrict;usewarnings;useutf8;useGlib::IO;useGtk4;# Create a new applicationmy$app=Gtk3::Application->new('com.example.Gtk3Application','G_APPLICATION_FLAGS_NONE');# When the application is launched…$app->signal_connect(activate=>sub{my$app=shift;# … create a new window …my$win=Gtk3::ApplicationWindow->new($app);# … with a button in it …my$btn=Gtk3::Button->new('Hello World!');# … which closes the window when clicked$btn->signal_connect(clicked=>sub{$win->close();});$win->set_child($btn);$win->present();});# Run the application$app->run(\@ARGV);
# Load Gtkimportgigi.require_version('Gtk','4.0')fromgi.repositoryimportGtk# When the application is launched…defon_activate(app):# … create a new window…win=Gtk.ApplicationWindow(application=app)# … with a button in it…btn=Gtk.Button(label='Hello, World!')# … which closes the window when clickedbtn.connect('clicked',lambdax:win.close())win.set_child(btn)win.present()# Create a new applicationapp=Gtk.Application(application_id='com.example.GtkApplication')app.connect('activate',on_activate)# Run the applicationapp.run(None)
useglib::clone;// glib and other dependencies are re-exported by the gtk crateusegtk::glib;usegtk::prelude::*;// When the application is launched…fnon_activate(application:>k::Application){// … create a new window …letwindow=gtk::ApplicationWindow::new(application);// … with a button in it …letbutton=gtk::Button::with_label("Hello World!");// … which closes the window when clickedbutton.connect_clicked(clone!(@weakwindow=>move|_|window.close()));window.set_child(Some(&button));window.present();}fnmain(){// Create a new application with the builder patternletapp=gtk::Application::builder().application_id("com.github.gtk-rs.examples.basic").build();app.connect_activate(on_activate);// Run the applicationapp.run();}
intmain(string[]argv){// Create a new applicationvarapp=newGtk.Application("com.example.GtkApplication",GLib.ApplicationFlags.FLAGS_NONE);app.activate.connect(()=>{// Create a new windowvarwindow=newGtk.ApplicationWindow(app);// Create a new buttonvarbutton=newGtk.Button.with_label("Hello, World!");// When the button is clicked, close the windowbutton.clicked.connect(()=>{window.close();});window.set_child(button);window.present();});returnapp.run(argv);}
Developers around the world have used GTK as a platform to create apps that solve problems faced by end-users.
GTK has all the features that a widget toolkit needs to have. These features make it the most trusted toolkit for developing Linux applications.
Projects built using GTK and its dependencies run on well known operating systems.
GTK delivers the enticing features and superb performance which adds to your applications.
GTK is written in C but has been designed to support a wide range of languages such as Python, JavaScript, C++, Rust andmany more.
GTK has a comprehensive collection of core widgets like Buttons, Windows, Toolbars for use in your application.
GTK is a free and open-source project maintained by GNOME and an active community of contributors. GTK is released under the terms of theGNU Lesser General Public License.
GTK boasts of an easy to useAPI which helps in decreasing your development time and help you achieve better results.
GTK caters to many features like Native look and feel, theme support, Object-oriented approach that today’s developers look for in a toolkit.
GTK is built on top of GLib. GLib provides the fundamental data types and system integration points to avoid duplicated code in applications.
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 thisexample application.
GTK is a large project and relies on volunteers from around the world. To help us with the project development, hack away on the existingbugs and feature requests.
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 GNOMEDiscourse instance, under thePlatform/Core category. You can use tags likegtk orglib to narrow down the topic of discussion to specific libraries. You can also ask questions in ourMatrix room.
As regularly as possible, GTK team meetings take place atconferences andhackfests to discuss the future of GTK and define aroadmap.
If you are a developer and want to contribute to GTK, you are more thanwelcome to do so.