many programmers import both gtk and pygtk in this way:
import gtk
import pygtk
I have created a simple program using only gtk and it works:
import gtk
window = gtk.Window()
window.set_size_request(800, 700)
window.set_position(gtk.WIN_POS_CENTER)
window.connect("destroy", gtk.main_quit)
button = gtk.Button("Vai")
button.set_size_request(30, 35)
button.connect("clicked", naviga)
testo = gtk.Entry()
h = gtk.HBox()
h.pack_start(testo)
h.pack_start(button)
window.add(h)
window.show_all()
gtk.main()
So... the question is: what is the difference from GTK and PYGTK ?
PyGTK is a cross-platform library. It is a free software distributed under the LGPL license.
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.
GTK is a multi-platform toolkit for creating graphical user interfaces. It is created in C language. GTK has been designed from the ground up to support a range of languages, including Python, Ruby, and Perl. The GTK library is also called the GIMP Toolkit.
PyGObject is a Python package which provides bindings for GObject based libraries such as GTK, GStreamer, WebKitGTK, GLib, GIO and many more. It supports Linux, Windows and macOS and works with Python 3.7+ and PyPy3. PyGObject, including this documentation, is licensed under the LGPLv2.
pygtk
is provided by python-gobject
.
gtk
is provided by python-gtk2
.
pygtk
provides the pygtk.require
function which allows you to require that a certain version of gtk (or better) is installed. For example
import pygtk
pygtk.require('2.0')
importing gtk
only is possible, but your program may not work as expected on someone else's machine if their version of gtk is older.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With