Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87572 > unrolled thread

Python+Glade+Gtk tutorial?

Started byDave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk>
First post2015-03-16 16:13 +0000
Last post2015-03-17 16:54 -0600
Articles 4 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Python+Glade+Gtk tutorial? Dave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> - 2015-03-16 16:13 +0000
    Re: Python+Glade+Gtk tutorial? Jason Heeris <jason.heeris@gmail.com> - 2015-03-17 16:22 +1100
      Re: Python+Glade+Gtk tutorial? Dave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> - 2015-03-17 20:52 +0000
    Re: Python+Glade+Gtk tutorial? Michael Torrie <torriem@gmail.com> - 2015-03-17 16:54 -0600

#87572 — Python+Glade+Gtk tutorial?

FromDave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk>
Date2015-03-16 16:13 +0000
SubjectPython+Glade+Gtk tutorial?
Message-ID<vgsdgahc4kf6pdt7822dke94upv56uhjbi@4ax.com>
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/

[toc] | [next] | [standalone]


#87622

FromJason Heeris <jason.heeris@gmail.com>
Date2015-03-17 16:22 +1100
Message-ID<mailman.489.1426569754.21433.python-list@python.org>
In reply to#87572

[Multipart message — attachments visible in raw view] — view raw

Warning: I'm only going to answer half of your questions :)

I haven't built any GTK2/3 app in a while, but hopefully others here can
address your other questions (although you might have better luck on the
Python/GTK mailing list when it comes to finding a good tutorial, etc.)

On 17 March 2015 at 03:13, Dave Farrance <
DaveFarrance@omitthisyahooandthis.co.uk> wrote:
> 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.

In terms of toolkit bindings, (a) I prefer GTK, but (b) it's impossible to
tell what the greater proportion of people using one vs. the other is. Or
if they're wise to do so. Are there more Google hits/SO questions because
it's harder to use? Or because everyone loves to use it? (And so on...)

A recent comment on my SO answer to a similar question claims PyQT/PySide
is a good way to go, with a couple of links there you might find
interesting: http://stackoverflow.com/a/3290724/188535

I wouldn't stress over it though; you can give yourself a headache trying
to decide between frameworks you've never developed in. Try one, commit to
developing at least some proficiency in it, and then try the other.

> "from gi.repository import Gtk, Gdk, GObject, Pango" etc...
>
> ... I get, in effect, the libraries used in Gnome-3 even with python2?

Yes. The GTK and Python versions are independent. You can make GTK3 apps
with either Python 2 or 3. It's purely coincidence that Python 3 and GTK3
came out around the same time.

Going the other way, Gnome 3 still includes some GTK2 apps, but I think
you'd get little sympathy for starting a *new* app in GTK2 instead of 3.

> 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?

Glade is good, although eventually you learn the lesson that it's not going
to give you 100% control over your UI — there are some things you are
better off doing in your app setup code.

And yes, I'd recommend ignoring anything labelled PyGTK.

— Jason

[toc] | [prev] | [next] | [standalone]


#87649

FromDave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk>
Date2015-03-17 20:52 +0000
Message-ID<0m4hga51bfidphso8lre41cub2llikmhkk@4ax.com>
In reply to#87622
Jason Heeris <jason.heeris@gmail.com> wrote:

>In terms of toolkit bindings, (a) I prefer GTK, but (b) it's impossible to
>tell what the greater proportion of people using one vs. the other is. Or
>if they're wise to do so. Are there more Google hits/SO questions because
>it's harder to use? Or because everyone loves to use it? (And so on...)
>
>A recent comment on my SO answer to a similar question claims PyQT/PySide
>is a good way to go, with a couple of links there you might find
>interesting: http://stackoverflow.com/a/3290724/188535
>
>I wouldn't stress over it though; you can give yourself a headache trying
>to decide between frameworks you've never developed in. Try one, commit to
>developing at least some proficiency in it, and then try the other.

OK, thanks.  I'll continue with Glade for now, and maybe try PyQT another
time.  Thanks for your answers to my questions.

[toc] | [prev] | [next] | [standalone]


#87654

FromMichael Torrie <torriem@gmail.com>
Date2015-03-17 16:54 -0600
Message-ID<mailman.505.1426632904.21433.python-list@python.org>
In reply to#87572
On 03/16/2015 10:13 AM, Dave Farrance wrote:
> 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/

Yes it's a good choice.  And even with Python 2, GTK3 is a good choice
also.  GTK3 bindings are done somewhat differently than GTK2.  They are
done in a more dynamic fashion through introspection. The nice thing is,
with the gi.repository thing (which stands for gobject introspection),
you can easily make Python bindings to any GObject-based C library.

If you want to use GTK2, that's also possible, and GtkBuilder does work
with it.  I can post an example if you want.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web