| FAQ Index - Search - Recent Changes - Everything - Add entry |
2.2. What are the major changes in PyGTK-2 for GTK+ 2.2?
The new PyGTK-2 is not fully compatible with the old one. There are a few things you will need to do to convert your app:
- Python 2.2 is required.
- The old, non-object-oriented C module _gtkmodule.so (accessed normally using "import _gtk" does not exist any more; this code will have to be converted to use the classes provided by the new pygtk.
- It is _strongly_ recommended that you use "import gtk" rather than "from gtk import *"
- The Gtk and Gdk prefixes on classes are gone. This can be fairly easily fixed with simple search and replace operations (gtk.GtkFoo goes to gtk.Foo, and gtk.GdkFoo goes to gtk.gdk.Foo).
- The GDK prefix for constants is gone and the GDK module is gone too. Now the constants are defined in the gtk.gdk module. For instance GDK_2BUTTON_PRESS is wrapped as gtk.gdk._2BUTTON_PRESS, and GDK_BUTTON_PRESS is gtk.gdk.BUTTON_PRESS.
- Widgets are now new style Python 2.2 classes. This probably won't affect anyone.
- Widgets that are considered "broken" (as opposed to deprecated) are not included in the binding. This list is fairly small though:
- GtkText (replaced by GtkTextBuffer/GtkTextView) - GtkTree and GtkTreeItem (replaced by GtkTreeView and GtkTreeModel)
- The new pygtk fixes a number of memory and reference leaks. This may cause you some problems as objects might get freed when previously they would have stayed around (ie. leaked). However, the changes should make PyGTK a bit more predictable.
- All GObjects now have at most one wrapper for their lifetime. This gets rid of the questions about what happens to the attributes set on an object when in a signal handler.
Overall, PyGTK-2 should be a much nicer PyGTK to program with. If you are working on new code, it would be best to use PyGTK-2 instead of 0.6.x.
What's more, there is even some documentation for PyGTK-2, available at [www.gnome.org]
