PyGTK
| PyGTK
| |
|---|---|
| Basisdaten
| |
| Hauptentwickler | James Henstridge |
| Aktuelle Version | 2.24.0[1] (1. April 2011) |
| Betriebssystem | Windows, Unix, macOS |
| Programmiersprache | Python |
| Kategorie | GUI-Toolkit |
| Lizenz | LGPL (Freie Software) |
| deutschsprachig | nein |
| www.pygtk.org | |

PyGTK ist eine Ansammlung von Wrappern für die Programmiersprache Python zum Zugriff auf das GUI-Toolkit GTK+. PyGTK ist als freie Software unter der LGPL lizenziert. Entwickelt wurde PyGTK von dem Gnome-Programmierer James Henstridge.
Mit dem Übergang zu GTK+ 3.0 und Gnome 3.0 wird PyGTK durch dessen Nachfolger PyGObject ersetzt, welches sich GObject-Introspektion zu Nutze macht, um Anbindungen an Bibliotheken automatisch zu erzeugen. PyGObject ist im Gegensatz zu PyGTK auch mit Python 3 kompatibel.
Python-Wrapper um vergleichbare GUI-Toolkits sind PyQt für die Qt-Bibliothek und wxPython für wxWidgets.
PyGObject Beispielprogramm
# ein mit PyGObject erstelltes Python-Programmes, welches GTK benutzt
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
# Die Klasse MeinFenster erbt von Gtk.Window
class MeinFenster(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="Hello World App")
self.set_size_request(300, 100)
# Einen Button erzeugen und dem Fenster hinzufügen
button = Gtk.Button(label="Klick hier")
button.connect("clicked", self.on_button_clicked)
self.add(button)
def on_button_clicked(self, widget):
# Ausgabe auf der Console bei Mauseklick auf den Button
print("Hello, Wikipedia!")
# Initializierung
app = MeinFenster()
app.connect("destroy", Gtk.main_quit) # Schließen
app.show_all()
# Die Hauptschleife der Anwendung wird durch den Aufruf von Gtk.main() gestartet.
# Diese Schleife wartet auf Ereignisse (wie Klicks) und aktualisiert die Anwendung entsprechend.
Gtk.main()
Weblinks
- Homepage (englisch)
- PyGTK FAQ (englisch)
- PyGTK-Tutorial (englisch)
- PyGObject Dokumentation (englisch)
Einzelnachweise
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.