Attention: PyGTK only supports the Gtk-2.X API (NOT Gtk-3.0) and the information on this page may be outdated. We strongly recommend not using PyGTK for new projects and to port existing applications from PyGTK to PyGObject. For more information see the PyGObject documentation.
PyGTK provides a convenient wrapper for the GTK+ library for use in Python programs, taking care of many of the boring details such as managing memory and type casting. When combined with PyORBit and gnome-python, it can be used to write full featured GNOME applications (see the Python page). Official website of PyGTK is : http://www.pygtk.org
GTK+ is a GUI toolkit for developing graphical applications that run on POSIX systems such as Linux, Windows and MacOS X (provided that an X server for MacOS X has been installed). It provides a comprehensive set of widgets, and supports Unicode and bidirectional text. It links into the Gnome Accessibility Framework through the ATK library.
Python is an interpreted, interactive, object-oriented programming language. It is often compared to Tcl, Perl, Scheme or Java. Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing.
/QuickStart -- PyGTK Quick Start Tutorial
/LearnByObservation -- Learn by observation!
Code repository access
Alternatively, you can get the bleeding edge version of PyGTK from the GNOME anonymous Git server git.gnome.org. Checkout the module pygtk, or if you want the GNOME extensions, just get the module gnome-python. More information on accessing and using GNOME's Git server is available in the Gnome Wiki.
Modules in Gnome Git: pygobject (which also includes dynamic Python bindings), pygtk (which is unmaintained and provides static Python bindings), gnome-python, gnome-python-desktop, gnome-python-extras, pygtk-docs
PyGTK "Hello, World!" Program
1 #!/usr/bin/env python 2 import pygtk 3 pygtk.require('2.0') 4 import gtk 5 # Create a new window 6 window = gtk.Window() 7 8 # Here we connect the "delete-event" event to a signal handler. 9 # This event occurs when we the user closes window, 10 # We connect it to gtk.main_quit, so it quits the main loop 11 # and the program terminates 12 window.connect("delete-event", gtk.main_quit) 13 14 # Sets the border width of the window. 15 window.set_border_width(10) 16 17 # Creates a new button with the label "Hello World". 18 button = gtk.Button("Hello World") 19 20 # This is a callback function, which we later will connect 21 # to the clicked signal of the button, which will be triggered 22 # when the user clicks the button with a mouse. 23 def on_button_clicked(button): 24 print "Hello World" 25 # When the button receives the "clicked" signal, it will call the 26 # function hello() defined above. 27 button.connect("clicked", on_button_clicked) 28 29 # This packs the button into the window (which is a container). 30 window.add(button) 31 32 # Show the window and the button 33 window.show_all() 34 # Run the main loop, to process events such a key presses 35 # and mouse movements. 36 gtk.main()
And the output of the above program will look like this:
Support and Feedback
There is a main mailing list for PyGTK. To subscribe to the list, use the web interface at
There is an IRC Channel called #pygtk in the irc.gnome.org (aka irc.gimp.net) network. People there are eager to help; go and meet some other PyGTK hackers!
Finding and reporting bugs is a excellent way to help improve PyGTK. If you think something is not working properly, you can ask on the mailing list or on the IRC channel; if a bug is in fact detected, the best way to ensure it is tracked and fixed is to file a bug report on GNOME's Bugzilla server.
To file a report follow these simple steps:
Create an account in Bugzilla at Gnome if you don't have one yet.
- Fill in as much information as you can in the Enter Bug form. A good Summary and Description are essential towards having your bug reproduced and fixed; test cases and code snippets are also very welcome.
- After clicking on the 'Submit Bug Report' you will be taken to the bug report itself. You can add comments, CC: other people, or attach files to the bug report. Useful files are small code examples that reproduce the bug, or stack traces of crashes.
PyGTK is included in most GNU/Linux distributions (including Connectiva, Debian, Fedora, Mandrake, Redhat, SUSE and Ubuntu); the source code can also be downloaded and compiled from the links below.
Current stable version (GTK+ 2.24.0)
Note: PyGTK 2.24 will be the last major release in the PyGTK series
If you want to make use of the Gnome libraries in your application, you may wish to install the gnome-python and gnome-python-desktop packages. In addition to this, gnome-python-extras is also available (contains less frequently used packages not in gnome-python). All are available from the Gnome FTP site and its mirrors:
For more, see the Python page.
Windows (Win32) Port
The Win32 port of PyGTK is maintained by John Stowers and Dieter Verfaillie.
You can get recent Win32 binaries and an all-in-one installer on the gnome ftp site: PyGTK for Win32 binaries. Note that the FAQ also includes a number of items on PyGTK and Win32. Instructions on building PyGTK on windows can be found here