Overview
PyGTK is a set of Python wrappers for the GTK+ graphical user interface library. It allows Python programs to easily integrate with the desktop environment with a rich and flexible set of GUI components.
Key features
- Wide range of standard widgets
- Support for custom widgets
- Comprehensive internationalization support
- Built-in accessibility features
- High portability across Linux, Windows, and macOS
Common use cases
- Building complex desktop applications
- Developing Linux applications with native look and feel
- Creating open source GUI applications
- Prototyping graphical user interfaces quickly
Installation
sudo apt-get install python3-gi sudo apt-get install python3-gi-cairo
Example
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Hello PyGTK")
self.set_border_width(10)
button = Gtk.Button(label="Click Here")
button.connect("clicked", self.on_button_clicked)
self.add(button)
def on_button_clicked(self, widget):
print("Hello World")
win = MyWindow()
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()