Re: From Tk to Gtk

On Mon, 05 Mar 2007 12:16:17 -0600
Judith <jaltamirano correolux com mx> wrote:

Hello every body I'm currently programming under perl Tk, but I want to 
move to perl Gtk, I want to know the diffrences between these two and 
wich is the last version of Gtk, thanks in advanced!!

< my 2 cents>
To me, the biggest difference between Tk and Gtk2 is the 
way you need to manage your callbacks and events in more
detail with Gtk2.

In Gtk2, the return value from
many callbacks determine if they will stop. 
It dosn't sound like much, but it represents a big
break in thinking from Tk's way of doing it. You will 
find all sorts of seemingly complex code in callbacks,
that sometimes return TRUE, sometimes FALSE; and
this determines the flow of the script. 

The event loop, adding and removing subs to it, is an
important feature of Gtk2, whearas Tk tends to hide
the internals of the Mainloop from you.  

One big advantage of Gtk2, is that it can be made thread-safe, and this is a
big step forward over Tk.

Another Gtk2 advantage, is that is uses the themes setup for your
other apps like mozilla or firefox.... so your Perl/Gtk2 programs
look like your other apps.

One big brick wall everyone runs into is the way lists are
handled in Gtk2. Tk is alot simpler, but Gtk2 does have the
the Ex and Simple series of list-releated modules to make it

Another advantage that Tk still has, is a better Canvas widget. The
Gnome2::Canvas has anti-aliasing, but otherwise, it is not as feature packed
as the Tk::Canvas. 

A very good intro to Gtk2 is

One other big advantage of Gtk2, is the underlying c libraries.
There is an active, and smart group of programmers working on
the libraries. If you look thru the c libraries at,
you will find many specialty libraries, ranging from OpenGL to
Window Manager control, etc. All of these libraries, could conceivably
be made into Perl/Gtk2 versions.

And finally, there is Glib. I find this one of the best parts of Gtk2.
It lets you setup an event loop in a command-line perl program,
which is extremely handy in writing simple scripts that will run
without X.

</2 cents>

So, my advice, is if you can afford the time, Gtk2 is worth it.
It has some very nice widgets like Gtk2::ImageViewer( which has
mouse zooming and panning), and things Tk can't do yet, like SVG. 

If you are pressed for time, Tk is quicker, but Gtk2 gives you a wider


I'm not really a human, but I play one on earth.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]