Python+Glade+Gtk tutorial?

Dave Farrance DaveFarrance at OMiTTHiSyahooANDTHiS.co.uk
Mon Mar 16 12:13:18 EDT 2015


In the past, I've used Visual-C++ for creating dialog-based interfaces for
controlling equipment and displaying data, and I'm looking for something
of similar ease-of-use in Python since that's now my preferred language.
A web-search told me that Glade seems to be most peoples choice (over
QT-Designer) for a GUI builder.  So even though I use a KDE desktop
(Kubuntu 14.10), I decided to try Glade.

So I web-searched for a Glade "hello world" example to get me started. The
top Google hit for that gave me a tutorial that only took a short time to
work through, and did convince me of Glade's ease-of-use, but the Python
code crashed.  Searching on the error-message told me that I needed to
select Glade's "libglade" output format instead of its "gtkbuilder" output
format to work with that tutorial.  Glade doesn't offer that option any
more -- you just get XML for "gtkbuilder".

So... I searched on "gtkbuilder hello world", which gave me the "Python
GTK+3 Tutorial" at readthedocs.org, and the Python code examples there
gave a somewhat different syntax, from which I was able to figure out how
to fix the tutorial, and then the code worked fine.

So am I understanding this correctly:  If I use this include line:

"from gi.repository import Gtk, Gdk, GObject, Pango" etc...

... I get, in effect, the libraries used in Gnome-3 even with python2?
Whatever "gi.repository" is?  It's a bit hard to figure this out from the
complexity of differing versions that I've turned up from Google searches.

Am I on the right track now?  Glade is a good choice for GUI building? And
even though I'm using Python2, I should be ignoring all examples turned up
by searching for "PyGTK" because they all seem to be GTK+2 and obsolete?
Is that "Python GTK+3 Tutorial" as good as any for me to work through?

https://python-gtk-3-tutorial.readthedocs.org/en/latest/



More information about the Python-list mailing list