Who is this book for?Edit
The book is targeted to people with at least some experience programming with Perl. General programming topics and semantics of the Perl programming language will not be discussed. The focus will be on using the Gtk2-Perl API to create graphical applications. If you are new to programming or to Perl - you should do some soul searching before continuing on.
What is Gtk+?Edit
Gtk is a library for creating graphical user interfaces. Gtk stands for the GIMP toolkit - named because it was developed for the GNU Image Manipulation Program. Gtk is free open-source software. It is licensed under the LGPL, which means you can develop free/open software or commercial software with it without paying licensing fees.
The Gtk+ libraries are written in the C programming language, but can be used from a multitude of other languages such as Perl, Python, Ruby, PHP, Java and others. A complete list of supported language bindings can be found at http://www.gtk.org/language-bindings.html.
Gtk2 is built on top of four primary components.
Gdk and gdk-pixbufEdit
The GIMP drawing kit and gdk-pixbuf are low level functions for window handling and image manipulation. The two Perl modules for these libraries can be found within the Gtk2 namespace as Gtk2::Gdk and Gtk2::Gdk::Pixbuf.
Glib replaces some native *nix call with it's own versions, to either add functionality or the increase portability of Gtk. Glib also provides the underlying type system behind Gtk's class hierarchy, the signal system used in Gtk, a thread API as well a facility for loading of modules. The Glib library is bound under the Glib namespace.
Pango is a library for handling (internationalized) text output. Pango is bound under the Gtk2 names space as Gtk2::Pango.
Gtk2-Perl is the name given to a set of Perl bindings for Gtk+ and related libraries. Using Gtk2-Perl requires that the following be installed on your system:
- Gtk+ binaries and dependencies
- Gtk2-Perl module and dependencies
Perl is most likely installed on your computer. If it's not - get it here.
Gtk+ is also probably installed on your system. If not, you should look for pre-built binaries on the internet specifically for your operating system. A simple Google search will most likely yield the results you are looking for. If there are no binaries available for your operating system, you can compile Gtk+ on your own.
Once you have Gtk+ and Perl on your system, you need to install the Perl language bindings. Like most great things perl, you can install the gtk-perl libraries via CPAN. Enter the following command at a prompt to automatically install.
perl -MCPAN -e 'install Gtk2'
If you have issues installing from the CPAN utility, you can download the module and install it manually. After downloading and extracting the archive, issues these commands from the root of the extracted folder.
Getting Gtk2 and Gtk2-Perl running on windows has its caveats, due to the fact that windows doesn't ship with all the necessary utilities to compile it(and lots of other great open-source software). Here are your three options.
The Easy WayEdit
1. Install latest version of ActiveState perl from here
2. Add sisyphusion repository in PPM (Select it from PPM Gui -> Edit -> Preference -> Repositories -> Suggested)
3. Install Glib, Gtk2, Cairo, Pango modules from sisyphusion repository.
And the recommended way. Download and install camelbox. Bam - you're done. The drawback is that things that are readily available from ActiveState's ppm repository like libexpat and libgd are not readily available with camelbox. It may be more difficult to compile these libraries, should you need them, than that it is to compile your own Gtk+ from source. In general, camelbox should be sufficient for most users and has the options and tools to install a lot of useful modules and utilities.
The Old Easy WayEdit
Follow the instructions at http://lostmind.de/gtk2-perl/. This website details everything you need to get Gtk2-perl working using ActiveState Perl 5.8.8 build 819. The drawback: it is all dated. It is an old version of Perl and more importantly and old version of Gtk+. There are a lot of features that have been implemented in both Gtk+ and the Perl language bindings that just did not exist at the time.
The Hard WayEdit
This is for advanced users. Build Gtk+ from source on your system. Build the gtk2-perl libraries against your Gtk+ and Perl builds. Instructions on how to do this are beyond the scope of this book.
- Peter Mattis firstname.lastname@example.org
- Spencer Kimball email@example.com
- Josh MacDonald firstname.lastname@example.org
Currently Maintained ByEdit
- Owen Taylor email@example.com
- Tim Janik firstname.lastname@example.org
- muppet email@example.com
- Ross McFarland firstname.lastname@example.org
- Torsten Schoenfeld email@example.com
- Marc Lehmann firstname.lastname@example.org
- Goran Thyni email@example.com
- Joern Reder firstname.lastname@example.org
- Chas Owens email@example.com
- Guillaume Cottenceau firstname.lastname@example.org