View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Brian Manning > Gtk3-0.034 > Gtk3



Annotate this POD



New  3
Open  1
View/Report Bugs
Module Version: 0.034   Source  


Gtk3 - Perl interface to the 3.x series of the gtk+ toolkit


  use Gtk3 -init;
  my $window = Gtk3::Window->new ('toplevel');
  my $button = Gtk3::Button->new ('Quit');
  $button->signal_connect (clicked => sub { Gtk3::main_quit });
  $window->add ($button);


Perl bindings to the 3.x series of the gtk+ toolkit. This module allows you to write graphical user interfaces in a Perlish and object-oriented way, freeing you from the casting and memory management in C, yet remaining very close in spirit to original API.


The Gtk3 module allows a Perl developer to use the gtk+ graphical user interface library. Find out more about gtk+ at

The gtk+ reference manual is also a handy companion when writing Gtk3 programs in Perl: The Perl bindings follow the C API very closely, and the C reference documentation should be considered the canonical source. The principles underlying the mapping from C to Perl are explained in the documentation of Glib::Object::Introspection, on which Gtk3 is based.

Glib::Object::Introspection also comes with the perli11ndoc program which displays the API reference documentation of all installed libraries organized in accordance with these principles.

Wrapped libraries

Gtk3 automatically sets up the following correspondence between C libraries and Perl packages:

  Library       | Package
  Gtk-3.0       | Gtk3
  Gdk-3.0       | Gtk3::Gdk
  GdkPixbuf-2.0 | Gtk3::Gdk
  Pango-1.0     | Pango

Import arguments

When importing Gtk3, you can pass -init as in use Gtk3 -init; to have Gtk3::init automatically called. You can also pass a version number to require a certain version of Gtk3.

Customizations and overrides

In order to make things more Perlish or to make porting from Gtk2 to Gtk3 easier, Gtk3 customizes the API generated by Glib::Object::Introspection in a few spots:

Perl compatibility

As of 5.20.0, perl does not automatically re-check the locale environment for changes. If a function thus changes the locale behind perl's back, problems might arise whenever numbers are formatted, for example when checking versions. To ensure perl's assumption about the locale are up-to-date, the functions Gtk3::init, init_check, init_with_args and parse_args are amended to let perl know of any changes.

Porting from Gtk2 to Gtk3

The majority of the API has not changed, so as a first approximation you can run s/Gtk2/Gtk3/ on your application. A big exception to this rule is APIs that were deprecated in gtk+ 2.x -- these were all removed from gtk+ 3.0 and thus from Gtk3. The migration guide at describes what to use instead. Apart from this, here is a list of some other incompatible differences between Gtk2 and Gtk3:

Note also that Gtk3::CHECK_VERSION will always fail when passed 2.y.z, so if you have any existing version checks in your code, you will most likely need to remove them.



Torsten Schönfeld <>


Copyright (C) 2011-2015 by Torsten Schoenfeld <>

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

syntax highlighting: