Saturday, May 21, 2011

Gtk3 Is Here

On February the 10th of 2011, Gtk+3 was released and, using this fresh Gtk+3 library, Gnome released Gnome 3.
Gtk+3 should be a "big clean up effort", our source quotes, and noteworthy features are:
  • cairo drawing throughout,
  • modern input device handling,
  • a new theming API ,
  • more flexible geometry management,
  • multiple backend support for Gdk,
  • easy application support,
  • and new widgets.
If you're someone that likes programming using Python, you may already be familiar with PyGtk. PyGtk however will no longer be developed to follow Gtk further than Gtk+2, and "users wishing to develop Python applications using Gtk+ are recommended to use the GObject-Introspection features available in PyGObject."
PyGobject is a Python dynamic module that enables developers to use the power of GObject which is part of the Gnome platform. The new Gtk+3 bindings will be found in this module.
I am using Ubuntu 11.04 as of this post, and I can't recall installing PyGobject, so if you are using the same distribution, you probably already have the module at your disposition. You can check that in your Python console by importing the PyGobject Introspection module (aka PyGI):

from gi.repository import Gtk
If no exception returns, you should be ready to code, but make sure you have the Gtk+3 repository:
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")

For those who are used to work with PyGtk, it may be wise to port your applications to PyGobject. More information on how to port PyGtk to PyGobject is available on line.
If you're an advanced programmer, the transition won't be hard on you, there are not so many changes. If, however, you are a novice in programming or new to GUI programming, you may find yourself in a bit more difficulties since there is little documentation as of yet on Python bindings. There are few demo's available (not all worked for me) and the Gtk+ documentation is written for C.
So you just may find yourself in the same situation as I am, left with your brain and fingers, and the wish to learn GUI programming with Python. You could just as well try other GUI libraries, like Qt4 or Wx. Because I like using Ubuntu, and because Gtk+ is at home on that OS, Gtk+ seemed like the proper choice to make for me.
Hence I have initiated this blog, open to any one who wants to join and share information on PyGI usage. I'm personally really interested in making styled (aka skinned or themed) applications, so I'll try to always add extra info on how to achieve this. In the worse of cases it will be a good way to keep notes and document what I am learning, in the best of cases it could become a platform for knowledge exchange and learning. Let's see how far we go :)

No comments:

Post a Comment