PyGTK

From Wikipedia, the free encyclopedia

Screenshot of WingIDE which is written using PyGTK. More screenshots
Screenshot of WingIDE which is written using PyGTK. More screenshots

PyGTK is a set of Python wrappers for the GTK+ GUI library. PyGTK is free software and licensed under the LGPL. Its original author is the famous GNOME developer James Henstridge. Today there are six people in the core development team, with various other people who have submitted patches and bug reports. PyGTK has been selected as the environment of choice for applications running on the One Laptop Per Child systems. Developers and interested parties can usually be found on the IRC channel #pygtk on irc.gnome.org.

PyGTK has been used in a number of notable applications, some examples:

[edit] Example: Hello World in PyGTK

import gtk

#Global variable 'count' stores the number of button clicks
count = 0

def button_pressed_cb(button):
    global count
    count += 1
    print "Hello again - the button was pressed: ", count, " time(s)."

window = gtk.Window()
window.set_title("Hello World!")

button = gtk.Button("Press me")
button.connect("clicked", button_pressed_cb)

window.add(button)
window.connect("delete-event", gtk.main_quit)
window.show_all()

gtk.main()

The sample program creates a GTK+ Window titled "Hello World!". The window contains a Button labelled "Press me." When the button is pressed, the message "Hello again - the button was pressed: X time(s)." (Note: X denotes the number of times the button was clicked) is displayed on the console via the callback button_pressed_cb. When the close button of the window is clicked, the program exits.

[edit] External links