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.
The current version of PyGTK requires Gtk+ >= 2.6 and Python >= 2.3 to build.
Contents
PyGTK Documentation
/QuickStart -- PyGTK Quick Start Tutorial
/WhatsNew212 -- What's New in PyGTK 2.12
/WhatsNew210 -- What's New in PyGTK 2.10
/WhatsNew28 -- What's New in PyGTK 2.8
/Cazaril -- Future API Plans
/LearnByObservation -- Learn by observation!
PyGTK Development
SVN Access
Alternatively, you can get the bleeding edge version of PyGTK from the GNOME anonymous SVN server svn.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 SVN server is available at the Gnome developer site.
Modules in Gnome SVN : pygobject, pygtk, 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
Mailing List
There is a main mailing list for PyGTK. To subscribe to the list, use the web interface at
The mailing address of the list is pygtk@daa.com.au . The mailing list is archived at mail-archive.com and at daa.com.au.
IRC Channel
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!
Bugzilla
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.
Visit the pygtk, the pyorbit or the gnome-python bug creation page, depending on which product your bug seems to present itself in.
- 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 Downloads
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 version (GTK+ 2.12.x)
The latest version of PyGTK for GTK+ 2.12.x is available from the following website:
Older versions (GTK+ 2.10.x 2.8.x, 2.6.x, 2.4.x, 2.2.x, 2.0.x, 1.x)
The latest version of PyGTK for GTK+ 2.10.x can be found at the following site:
The latest version of PyGTK for GTK+ 2.8.x can be found at the following site:
The latest version of PyGTK for GTK+ 2.6.x can be found at the following site:
The latest version of PyGTK for GTK+ 2.4.x can be found at the following site:
The latest version of PyGTK for GTK+ 2.2.x can be found at the following site:
The latest version of PyGTK for GTK+ 2.0.x can be found at the following site:
The latest version of PyGTK for GTK+ 1.2.x can be found at the following site:
If you are writing a new program, it is strongly recommended that you use the latest GTK+ 2.x version of PyGTK instead.
GNOME dependencies
If you want to make use of the Gnome libraries in your application, you will also need to install the PyORBit and gnome-python packages. They are available from the Gnome FTP site and its mirrors:
In addition to this, now gnome-python-extras is also available (packages not fits in gnome-python)
For more, see the Python page.
Windows (Win32) Port
The Win32 port of PyGTK is maintained by Cedric Gustin. You can get recent Win32 binaries on the gnome ftp site: PyGTK for Win32 binaries. Note that the FAQ also includes a number of items on PyGTK and Win32.
Deprecated
To check out pygtk cvs :
$ export CVSROOT=":pserver:anonymous@anoncvs.gnome.org:/cvs/gnome" $ cvs login #Simply press 'Return/Enter' key when asking for password $ cvs -z3 co pygtk
