GTK2-Perl is a set of Perl wrappers for the GTK + GUI libraries and other GNOME libraries. GTK2-Perl is an open source software licensed under the LGPL license. Developers and stakeholders can usually be found on the # gtk-perl IRC channel on irc.gnome.org.
GTK2-Perl is part of the official GNOME Platform Bindings [1] release, along with interfaces to C ++ , Python, and Java .
Example
use Gtk2 '-init' ;
$ window = Gtk2 :: Window -> new ( 'toplevel' );
$ window -> set_title ( "Hello World!" );
$ button = Gtk2 :: Button -> new ( "Press me" );
$ button -> signal_connect ( clicked => sub { print "Hello again - the button was pressed \ n" ; });
$ window -> add ( $ button );
$ window -> show_all ;
Gtk2 -> main ;
0 ;
In this example, a GTK + Window
with the title “Hello World!”. The window contains a Button
labeled “Press me." When the user presses the button, the callback function associated with the cliked signal of the button is called. This function displays the message "Hello again - the button was pressed" to the console. It should be noted that in this case the callback function is anonymous (does not have a name) and is declared directly in the call arguments of the signal_connect
function, which connects the signals and callback functions specified by the user.