Grant Edwards writes: > Is pygobject the replacement for pygtk? The easiest way to use it, if you want a quick port with the fewest code changes, is:
from gi import pygtkcompat pygtkcompat.enable() pygtkcompat.enable_gtk(version='3.0') I don't know if pygtkcompat is going to be supported forever, or will eventually be deprecated, but it does make porting very easy. The harder way, from gi.repository import Gtk (plus Gdk, GdkPixbuf, Pango, PangoCairo etc.) might be more future-proof but requires more porting effort. Grant Edwards writes: > I assume that difference is because pygtk was hand-written and gi is > built auto-magically using SWIG or something like that? Right. Which also has the unfortunate side effect that gi-imported libraries usually have no built-in documentation -- you can't learn much by typing help(object) or help(classname) in the Python console. So you usually have to use the C documentation and guess at the Python signatures. > For native Linux apps I definitely prefer Gtk. The other choices are > extra complexity doesn't ever seem to buy me anything except > MS-Windows compatibility [which did matter for a few of the apps I > used to maintain]. The last time I looked into Gtk on Windows, it > didn't sound usable, but that was many years ago. A few years ago, pip install pygtk worked on Windows for gtk2 (in fact, it *only* worked on Windows; it didn't work on Mac or Linux). I suspect you can install the new gi version of GTK3 etc. via pip3, but I haven't actually verified that. On Mac, python-gtk2 was extremely difficult to install. I hope python3/gi/GTK3 is easier. You can install these packages via pip now on Linux, so I'd hope that's true on Mac as well. > * PyQt -- I run Gtk-centric Linux systems, and the second you try to > use one Qt widget, it always seems to pull in hundreds of packages > that take a week to build. I haven't generally found that about PyQt. Most KDE apps do pull in hundreds of packages, but I haven't had to install that many just to use PyQt. I usually prefer GTK, but there are a few things PyQt offers that aren't available in GTK any more, like an HTML browser/viewer: python-webkit was only available for Python2 and there seems to be no GTK web viewer option now, whereas PyQt5.QtWebEngineWidgets allow for a reasonably functional, if not particularly well documented or configurable, HTML viewer. > * WxPython - It's bigger and far more complex than pygtk/gi and > [ ... ] > * Tkinter -- It's ugly on Linux (yea, I know there are supposed to be TkInter and WxPython are fine for bringing up a quick window, but when I've tried to use them for more complex apps, I usually hit limitations in low-level areas like event handling or window management. Though admittedly it's been years since I tried to write anything nontrivial in either one, and they may have matured. Grant Edwards writes: > I'm still trying to figure out to "freeze" the size of a button so > that when I change its contained label text on-the-fly it doesn't > resize and shift everying else slightly. I don't remember that > happening with gtk2 (which I can no longer run), but I've no idea > why... If you figure that out, let me know: I have a couple of apps that have that problem as well, and I've just been putting up with it. ...Akkana -- https://mail.python.org/mailman/listinfo/python-list