GTK2-Perl is the collective name for a set of perl bindings for GTK+ 2.x and various related libraries. These modules make it easy to write Gtk and Gnome applications using a natural, perlish, object-oriented syntax.
GTK+ is a GUI toolkit for developing graphical applications that run on POSIX systems such as Linux, Windows and MacOS X (provided that an X server for MacOS X has been installed). It provides a comprehensive set of widgets, and supports Unicode and bidirectional text. It links into the Gnome Accessibility Framework through the ATK library.
Perl is a stable, multi-platform programming language, used throughout the entire Internet and in many mission-critical environments.
GTK2-Perl is part of the official GNOME Platform Bindings
GTK2-Perl Resources
Official web site: http://gtk2-perl.sourceforge.net
GTK2-Perl Documentation
GTK2-Perl Modules
Gnome Platform Bindings Modules
These modules are actively maintained, and follow the Gnome Release Schedule.
Name
Description
Latest Release
Glib
GLib 2.0 bindings
1.100
Gtk2
Gtk+ 2.0 bindings
1.100
Gtk2::GladeXML
UI building library
1.005
Gnome2
Gnome and Gnome UI bindings
1.023
Gnome2::Canvas
A structured graphics canvas
1.002
Gnome2::VFS
Gnome VFS bindings
1.041
Gnome2::GConf
GConf bindings
1.021
Other Modules
These modules reside in the GTK2-Perl CVS server, and do not follow a strict release schedule.
Name
Description
Latest Release
Notes
Gnome2::Print
Gnome Print infrastructure
0.951
release candidate
Gnome2::VTE
Terminal emulator widget
0.04
Gnome2::RSVG
SVG parser and display library
0.05
Gnome2::Dia
Diagrams
0.04
Gnome2::Wnck
Window navigator construction kit
0.11
GStreamer
Audio/Video infrastructure
0.04
GStreamer::GConf
GConf interaction facilities for GStreamer
0.01
Gtk2::GLExt
3D modelling using OpenGL
0.90
Gtk2::HTML2
HTML viewer widget
0.04
Gtk2::MozEmbed
HTML viewer widget using the Gecko rendering engine
0.04
Gtk2::SourceView
Powerful editor widget
1.000
stable
Gtk2::Spell
Spellcheck widget
1.03
Gtk2::TrayIcon
Notification area icon
0.04
GTK2-Perl Development
You can browse the GTK2-Perl CVS here.
To check out GTK2-Perl CVS:
export CVSROOT=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/gtk2-perl" cvs login # Just press Enter when asked for a password cvs -z3 co gtk2-perl-xs
GTK2-Perl "Hello, World!" Program
use strict;
use warnings;
use Glib qw/TRUE FALSE/; # import TRUE and FALSE constants for readability
use Gtk2 '-init'; # load Gtk2 module, and initialize it
my $window = Gtk2::Window->new('toplevel'); # create a new window
# Here we connect the "destroy" event to a signal handler.
# This event occurs when we call Gtk2::Widget::destroy on the window.
# Perl supports anonymous subs, so we can use one of them for one line
# callbacks.
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
# Sets the border width of the window.
$window->set_border_width(10);
# Creates a new button with a label "Hello World".
my $button = Gtk2::Button->new("Hello World");
$button->signal_connect(clicked => sub {
my ($button) = @_;
print "Hello, World!\n";
# We can use variables defined outside the sub's scope, thanks
# to Perl closures.
$window->destroy;
});
# This packs the button into the window (a gtk container).
$window->add($button);
# The final step is to display this newly created widget.
$button->show;
# and the window
$window->show;
# All GTK applications must have a call to the main() method. Control ends here
# and waits for an event to occur (like a key press or a mouse event).
Gtk2->main;
0;