PyGTK#Syntax

{{Short description|Set of Python wrappers for the GTK graphical user interface library}}

{{Infobox software

| name = PyGTK

| title =

| logo =

| screenshot = PyGTK-Screenshot-Hello-World.png

| caption = Screenshot

| collapsible =

| author = James Henstridge{{cite web

| url = http://www.jamesh.id.au/

| title = Software I have written > PyGTK - Python bindings for GTK

| publisher = James Henstridge's Homepage}}

| developer = PyGTK Core development team{{cite web

| url = http://pygtk.org/about.html

| title = The people behind PyGTK}}

| released =

| discontinued = yes

| latest release version = 2.24.0{{cite web

| url = http://ftp.gnome.org/pub/GNOME/sources/pygtk/

| title = PyGTK download page}}

| latest release date = {{Start date and age|2011|04|01|df=yes/no}}

| latest preview version =

| latest preview date =

| programming language = Python, C

| operating system = Cross-platform

| platform = Cross-platform

| size =

| language =

| genre = Widget toolkit

| license = LGPL

| website = {{URL|pygtk.org}}

}}

{{Main|List of language bindings for GTK}}

PyGTK is a set of Python wrappers for the GTK graphical user interface library. PyGTK is free software and licensed under the LGPL. It is analogous to PyQt/PySide and wxPython, the Python wrappers for Qt and wxWidgets, respectively. Its original author is GNOME developer James Henstridge. 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 One Laptop Per Child systems.

PyGTK will be phased out with the transition to GTK version 3 and be replaced with PyGObject,{{cite web|url=https://wiki.gnome.org/PyGObject|title=PyGObject|publisher=wiki.gnome.org}}{{cite web|url=https://www.openhub.net/p/pygobject|title=Black Duck Open Hub: PyGObject}} which uses GObject Introspection to generate bindings for Python and other languages on the fly. This is expected to eliminate the delay between GTK updates and corresponding language binding updates, as well as reduce maintenance burden on the developers.{{cite web|url=http://live.gnome.org/action/recall/GObjectIntrospection?action=recall&rev=69|archive-url=https://archive.today/20120711012345/http://live.gnome.org/action/recall/GObjectIntrospection?action=recall&rev=69|url-status=dead|archive-date=2012-07-11|title=GObject Introspection}}

Syntax

The Python code below will produce a 200x200 pixel window with the words "Hello World" inside.

import gtk

def create_window():

window = gtk.Window()

window.set_default_size(200, 200)

window.connect("destroy", gtk.main_quit)

label = gtk.Label("Hello World")

window.add(label)

label.show()

window.show()

create_window()

gtk.main()

=Notable applications that have used PyGTK=

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

{{div col}}

{{div col end}}

PyGObject

{{Infobox software

| name = GTK

| title = PyGObject

| logo =

| screenshot =

| caption =

| collapsible =

| author =

| developer =

| released =

| latest release version = {{wikidata|property|preferred|references|edit|Q16948079|P348|P548=Q2804309}}

| latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|Q16948079|P348|P548=Q2804309|P577}}|df=yes}}

| repo = {{URL|{{wikidata|property|preferred|Q16948079|P1324}} }}

| programming language = Python, C

| size =

| language =

| genre = Widget toolkit

| license = LGPL

| website = {{URL|{{wikidata|property|preferred|Q16948079|P856}} }}

}}

PyGObject provides a wrapper for use in Python programs when accessing GObject libraries. GObject is an object system used by GTK, GLib, GIO, GStreamer and other libraries.

Like the GObject library itself, PyGObject is licensed under the GNU LGPL, so it is suitable for use in both free software and proprietary applications. It is already in use in many applications ranging from small single-purpose scripts to large full-featured applications.

PyGObject can dynamically access any GObject libraries that use GObject Introspection. It replaces the need for separate modules such as PyGTK, GIO and python-gnome to build a full GNOME 3.0 application. Once new functionality is added to GObject library it is instantly available as a Python API without the need for intermediate Python glue.

=Notable applications that use PyGObject=

PyGObject has replaced PyGTK, but it has taken a considerable amount of time for many programs to be ported. Most of the software listed here has an older version which used PyGTK.

{{div col}}

{{div col end}}

See also

{{Portal|Free and open-source software}}

  • PyQt (Python wrapper for the Qt toolkit)
  • PySide (Alternative Python wrapper for the Qt toolkit)
  • wxPython (Python wrapper for the wx widgets collection)

References

{{Reflist}}