Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get started in GUI Programming?

48 views
Skip to first unread message

peter....@talk21.com

unread,
Nov 25, 2005, 9:02:40 AM11/25/05
to
I am trying to learn GUI programming in Python, but have to confess I
am finding it difficult.

I am not an experienced programmer - just someone who from time to
time writes small programs for my use. Over the years I have moved
from GWBASIC to QBASIC to Visual Basic, and now trying to move across
to a Linux platform. Python seems to be the best compromise between
the limitations of command line basic programming and the total
incomprehensibility of C.

Googling around it seems the best GUI is either Tkinter or PyGtk. I
found a book which recommended PyGtk, as it had a graphical design
option, Glade. Coming from a VB background I latched onto that and
bought the book (Beginning Python, Wrox), but it was a disappointment
(or more accurately a complete waste of money) - there was
insufficient detail in the text.

I've found the tutorial and reference manual on the PyGtk web site,
but although I've made some progress, I keep reaching points where I
have insufficient background to understand them. Currently I'm stuck
on dialog boxes (the code seems immensely complex for the equivalent of
MsgBox("Do you really want to do this ",vbYesNo) and I haven't
got it to work properly yet) and loading graphical images in anything
other than their original size, but every new step brings another
struggle

I've seen reference to a Tkinter book - something like 'Python
and Tkinter Programming' but it seems to be out of print and
unavailable.

Can anyone offer any suggestions as to the least painful way forwards?

(Email address was valid once but has long since been abandoned to
spam. Please rely via newsgroup)

Sybren Stuvel

unread,
Nov 25, 2005, 9:17:41 AM11/25/05
to
peter....@talk21.com enlightened us with:

> Googling around it seems the best GUI is either Tkinter or PyGtk.

I'd go for wxPython ;-)

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa

Thomas Guettler

unread,
Nov 25, 2005, 9:35:59 AM11/25/05
to
Am Fri, 25 Nov 2005 06:02:40 -0800 schrieb peter.mosley:

> I am trying to learn GUI programming in Python, but have to confess I
> am finding it difficult.

Yes, if you come from Visual Basic you might be missing something.
I developed with Visual Basic some time ago and like some parts of it.


> I've found the tutorial and reference manual on the PyGtk web site,
> but although I've made some progress, I keep reaching points where I
> have insufficient background to understand them. Currently I'm stuck
> on dialog boxes (the code seems immensely complex for the equivalent of
> MsgBox("Do you really want to do this ",vbYesNo)

search for yesNoDialog here:
http://guettli.sourceforge.net/gthumpy/src/editMetadata.py

> and I haven't
> got it to work properly yet) and loading graphical images in anything
> other than their original size, but every new step brings another
> struggle

search for scale2pixbuf in the link.



> Can anyone offer any suggestions as to the least painful way forwards?

Only the beginning is painful. After some time you don't miss anything
from Visual Basic anymore.

Happy Learning,
Thomas


--
Thomas Güttler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: niemand....@thomas-guettler.de

Peter Decker

unread,
Nov 25, 2005, 9:57:57 AM11/25/05
to pytho...@python.org
On 11/25/05, Sybren Stuvel <sybr...@yourthirdtower.com.imagination>

> I'd go for wxPython ;-)

I'd go for Dabo, which is a Pythonic wrapper around wxPython. They are
even working on a visual design tool to lay out your UI, much as you
would in Visual Basic.

--

# p.d.

Szabolcs Nagy

unread,
Nov 25, 2005, 10:11:42 AM11/25/05
to

Steve

unread,
Nov 25, 2005, 10:33:17 AM11/25/05
to
> Can anyone offer any suggestions as to the least painful way forwards?

http://www.ferg.org/easygui/index.html

UrsusM...@gmail.com

unread,
Nov 25, 2005, 11:12:18 AM11/25/05
to
Hello Peter,

I am going to recommend EasyGui which can be found at
http://www.ferg.org/easygui/ because it is (by far) the easiest
possible GUI creation tool using Python.

If (or when) your needs require more complex options than easygui
provides, you might try looking at my GUI toolkits page,
http://www.awaretek.com/toolkits.html which has short descriptions of
and links to several Python GUI toolkits. Among these, my personal
favorite is PythonCard which is a framework that uses a visual GUI
creation tool and uses the wxPython widgets. I have found PythonCard to
be much easier to get started with than Glade.

I also did a podcast describing Python's GUI options, from a beginner's
point of view, which can be found on my Python podcasts page,
http://www.awaretek.com/python/index.html (scroll down to near the
bottom to find the "Choose Your GUI Toolkit" podcast from back in July.


But by all means don't forget to check out Easygui. Steve Ferg has made
a tool that is incredibly simple to learn and use, and sometimes it
sure is nice to get instant gratification by achieving quick success
and useful results. ;-)))

Ron Stephens
<a href="http://www.awaretek.com/plf.html">Python Learning
Foundation</a>

pdalet

unread,
Nov 25, 2005, 11:27:07 AM11/25/05
to
If you come from visual basic, I suggest to use pythoncard GUI, which
is
very simple to develop with a Ressource Editor (create a panel, see
labwindows, visual basic ..).

https://sourceforge.net/projects/vb2py/
a package to transform VB to pythoncard

http://www.linux2000.com/pimp.html
a pythoncard application


Philippe DALET
Lyp champollion
46100 FIGEAC
FRANCE


peter....@talk21.com a écrit :

flamesrock

unread,
Nov 25, 2005, 11:56:53 AM11/25/05
to
The best, in my opinion is wxPython.

I recommend getting wxGlade and just fiddling around. You should be
able to produce some interesting GUI's fairly easily.

BartlebyScrivener

unread,
Nov 25, 2005, 12:05:54 PM11/25/05
to
Search this group for PythonCard and wxPython for gobs of opinions. For
descriptions of other resources, try:

http://www.fredshack.com/docs/python.html

bs

David Boddie

unread,
Nov 25, 2005, 12:25:37 PM11/25/05
to
peter....@talk21.com wrote:
> I am trying to learn GUI programming in Python, but have to confess I
> am finding it difficult.
>
> I am not an experienced programmer - just someone who from time to
> time writes small programs for my use. Over the years I have moved
> from GWBASIC to QBASIC to Visual Basic, and now trying to move across
> to a Linux platform. Python seems to be the best compromise between
> the limitations of command line basic programming and the total
> incomprehensibility of C.
>
> Googling around it seems the best GUI is either Tkinter or PyGtk.

You might also want to try PyQt:

http://www.riverbankcomputing.co.uk/pyqt/

I'm sure fans of wxWidgets will also point you in the direction of
their favourite bindings. ;-)

David

Thomas Guettler

unread,
Nov 25, 2005, 1:21:19 PM11/25/05
to
Am Fri, 25 Nov 2005 06:02:40 -0800 schrieb peter.mosley:

> I am trying to learn GUI programming in Python, but have to confess
I
> am finding it difficult.
>

Yes, if you come from Visual Basic you might be missing something.
I developed with Visual Basic some time ago and like some parts of it.

> I've found the tutorial and reference manual on the PyGtk web site,
> but although I've made some progress, I keep reaching points where I
> have insufficient background to understand them. Currently I'm stuck
> on dialog boxes (the code seems immensely complex for the equivalent
of
> MsgBox("Do you really want to do this ",vbYesNo)
>

> and I haven't


> got it to work properly yet) and loading graphical images in
anything
> other than their original size, but every new step brings another
> struggle
>

search for scale2pixbuf in the link.

> Can anyone offer any suggestions as to the least painful way
forwards?
>

malv

unread,
Nov 25, 2005, 1:29:52 PM11/25/05
to
I suggest you take a look at Qt3, much superior to Tkinter or PyGtk.
With Python, you have to use PyQt bindings.

BartlebyScrivener

unread,
Nov 25, 2005, 2:04:37 PM11/25/05
to
Search this group for PythonCard and wxPython for many posts on this
subject. Also see the following link for descriptions of other
alternatives:

http://www.fredshack.com/docs/python.html

bs

Bill

unread,
Nov 25, 2005, 2:31:24 PM11/25/05
to
peter....@talk21.com wrote:
> I am trying to learn GUI programming in Python, but have to confess I
> am finding it difficult.
>
> Googling around it seems the best GUI is either Tkinter or PyGtk.

This statement is, and has been subject to much debate. If you ask 10
people on this newsgroup you'll probably get 12 opinions.

If you're having trouble at this early stage, you might want to
reconsider and take another look at either QT or wxWidgets. I've been
through the QT tutorial and was quite satisfied with it, although I'll
admit I was not a GUI newby at the time. I also found the tutorial
accompanying Boa Constructor (http://boa-constructor.sourceforge.net/)
to be a good start at creating a wxWidgets GUI.

Bill

jay...@gmail.com

unread,
Nov 25, 2005, 4:30:00 PM11/25/05
to
did you search GUI in this group? I think the results will be helpful.
some other GUI packages you might of missed are wxPython and pygame

BartlebyScrivener

unread,
Nov 25, 2005, 4:48:15 PM11/25/05
to

I responded twice to this but it didn't post. Weird. Anyway, search for
PythonCard and wxPython in this group. And then, for more options,
check this page:

http://www.fredshack.com/docs/python.html

bs

jmdes...@gmail.com

unread,
Nov 25, 2005, 5:27:03 PM11/25/05
to
It all really depends on what you wish to achieve. Results are
generally in proportion to the effort involved.
I don't think a "Python for Nulls" exists !
the following thread deals with documentation for beginners (and others
as well)
http://groups.google.ca/group/comp.lang.python/browse_frm/thread/4b7a01e1feb128fa/2b6b186a96c4fa73?hl=en#2b6b186a96c4fa73

For Tkinter the basic document is Fredrik Lundh's 'Introduction to
Tkinter' (you can google to easily find this)
and also one from New Mexico Tech at
http://infohost.nmt.edu/tcc/help/lang/python/tkinter.html

If you're intent on doing image manipulation, I would advise that you
consider the Python Imaging Library (known as PIL).

Pain is a very personal concept - what can be a painful endeavor for
some might be a enticing challenge for another ;-)

Good luck.

gsteff

unread,
Nov 25, 2005, 6:25:58 PM11/25/05
to
I learned pygtk via the tutorial and reference manual, and found most
things to be pleasantly simple to do. A message dialog, for example,
can be done via

dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK_CANCEL,
message_format="Test message here.")
response = dialog.run()

All that can be found by looking up the MessageDialog class in the
reference manual, noticing that there's not much there, and looking
and the documentation for its parent "Dialog" class. That may be one
source of confusion you may have experiened while reading the reference
manual.

In general, I've found pygtk to be remarkably pythonic (for an
interface to a library that has been ported to many other languages as
well). For example, when using tree views, you can access the tree
model underlying it using the normal python list syntax, which I think
is very cool. If you have other examples of things that are confusing,
post them (here, or to the pygtk list).

Greg

Message has been deleted
Message has been deleted

Jonathan Gardner

unread,
Nov 26, 2005, 1:16:49 PM11/26/05
to
I would argue with your assertion that either TKinter of PyGTK are the
best. There are several other good alternatives, including wxPython and
PyQt, which are very comparable, if not better.

I would strongly suggest starting with PyQt. It's my personal favorite.
I wrote a short tutorial on the Python Wiki.

http://wiki.python.org/moin/JonathanGardnerPyQtTutorial

I find that the Qt API is a lot simpler than the alternatives. Plus, it
has great documentation.

Rembrant

unread,
Nov 26, 2005, 1:23:39 PM11/26/05
to
ok i'm begginer in programing but i found some online books so you'll
probably find in them what you need! Just send me a mail and i'll reply
with the address! hope this can be helpfull...

Luis M. Gonzalez

unread,
Nov 26, 2005, 1:52:22 PM11/26/05
to
Try PythonCard (http://pythoncard.sf.net).
Like VB or Delphi (drag and drop widgets), but much simpler, easy and
fun.
It's based on wxWidgets, and it gives your apps a native look, no
matter your platform (much nicer than Tkinter, which looks uglier and
dated).

Claudio Grondi

unread,
Nov 27, 2005, 8:56:22 AM11/27/05
to

<peter....@talk21.com> schrieb im Newsbeitrag
news:1132927360....@f14g2000cwb.googlegroups.com...

From what you write I conclude, that it is maybe a very good idea to stay
with Visual Basic and use it to create the appropriate ActiveX components
you need in Python and then register them to use it from Python. This way
you can 'marry' what you have already created in Visual Basic easily with
Python.
From what I currently know, there is no 100% cross-platform solution for GUI
related tasks, because each platform has own specifics which usually are
very interesting for use in own programming and that kills as a consequence
the cross-platform usage.

# For example a Yes/No/Abort dialog box can be achieved using the WSHOM.OCX
available in Windows as follows:

import win32com.client
axWshShell = win32com.client.Dispatch("WScript.Shell") # WSHOM.OCX

axWshShell_Popup_Icon_Critical = 16
axWshShell_Popup_Button_AbortRetryIgnore = 2
axWshShell_Popup_NoAutoclose = 0

intRetVal = axWshShell.Popup(
### Raise a message box:
" The Popup() Text" + "\n" +
"",
axWshShell_Popup_NoAutoclose,
" The Popup() Title:",
axWshShell_Popup_Icon_Critical + axWshShell_Popup_Button_AbortRetryIgnore
)

axWshShell_Popup_Clicked_Abort = 3 # [Abort] button
axWshShell_Popup_Clicked_Retry = 4 # [Retry] button
axWshShell_Popup_Clicked_Ignore = 5 # [Ignore] button

if(intRetVal == axWshShell_Popup_Clicked_Abort):
print 'Abort clicked, return value = %i'%(intRetVal,)

if(intRetVal == axWshShell_Popup_Clicked_Retry):
print 'Retry clicked, return value = %i'%(intRetVal,)

if(intRetVal == axWshShell_Popup_Clicked_Ignore):
print 'Ignore clicked, return value = %i'%(intRetVal,)

Hope this is what are you looking for, isn't it?

Claudio


Kay Schluehr

unread,
Nov 27, 2005, 9:16:17 AM11/27/05
to

peter....@talk21.com wrote:
> I am trying to learn GUI programming in Python, but have to confess I
> am finding it difficult.

Don't do it if you can prevent it.

GUI - toolkits are very complex beasts and at least to me a source of
pain far more as a joy. Python cannot help you making them
significantly simpler but on the contrary add just another level of
indirection. Python normally shines when you have to glue libraries
together or programming simply Python scripts for a broad range of
purposes but if the wrapped library publishes a huge interface with
hundreds of classes and thousands of methods and attributes the benfit
of Pythons abstraction converges to zero. Python does not offer a good
toolchain to take up with Swing, WinForms or Qt to name just a few
delivered with IDEs that are very helpfull in developing GUI apps. Not
to talk about documentation...

Conclusion: if you are already familiar with BASIC I would just
continue writing BASIC apps using VisualBasic dotNet, Windows Forms as
the underlying GUI toolktit and VisualStudio as IDE. Forget the
coolness factor of the language. Cool people never care a lot what
other people think. If you finally want to glue assemblys/controls
together in Python this is still possible with IronPython or
Python-dotNet ( which is a CPython binding to the CLR, available at
Zope.org ).

paron

unread,
Nov 28, 2005, 6:51:31 AM11/28/05
to
I think the best route is through the browser. Good cross-platform, has
a reasonable toolkit, and it's familiar for users.

You could look at TurboGears.

UrsusM...@gmail.com

unread,
Nov 28, 2005, 7:52:51 AM11/28/05
to
I agree with Paron, using HTML forms and such as a minimal GUI front
end meant to be run in a browser is often a good way to go.

But I just want to mention, again, Stephen Ferg's "Easygui" at
http://www.ferg.org/easygui/index.html which is a very easy way to go
for desktop GUI's. You know, I just had a thought: I wonder if Easygui
could be used on handhelds like Pocket PC's, Zaurus, Palm etc? If it
could just be imported as a module it might be an awfully simple way to
create GUI's for handhelds.


Ron Stephens
http://www.awaretek.com/plf.html

forod...@gmail.com

unread,
Nov 28, 2005, 8:29:00 AM11/28/05
to
Have you tried Gambas?
http://gambas.sourceforge.net

It's a VB-like tool.
But the programming language is not Pyhton :-(

peter....@talk21.com

unread,
Nov 28, 2005, 9:06:33 AM11/28/05
to
A big thank you to all who responded. There are too many to reply
individually, but to summarise ...

Thomas Güttler gave a link to an example program, editMetadata.py
which uses yes no dialogs and scaled images. I've not yet tried to
learn from this, but looking at the code it seems to provide exactly
what I am looking for. It uses the gtkMessageDialog class, which I
hadn't come across (the tutorial doesn't seem to mention it?)

Others recommended wxPython, PyQt and various derivatives. The trouble
is there's too much choice! But my experience is that under Linux
nothing ever works out of the box, and so I am reluctant to invite more
grief by installing fresh packages until I am sure those already
installed are not adequate.

Easygui had some supporters. I had already come across this, and while
I agree it is a delightfully simple tool to use, and ideal for i/o
operations, it is not sufficiently flexible for my needs.

One development is that my local public library has, to my surprise,
managed to locate a copy of 'Python and Tkinter Programming' by J.
Grayson. I've not read it yet, and an initial flick through
doesn't look too promising but maybe I am mistaken.. I acknowledge
that Tkinter is a bit dated, and may not have a native 'look and
feel', but for me this would be outweighed by an accessible textbook.

So currently the choice is between continuing with PyGtk, using the
editMetadata.py code as a model, or Tkinter using Grayson's book.
I'll try both and see which is more successful.

Once again thank you to all who responded.

Brian Elmegaard

unread,
Nov 28, 2005, 9:45:57 AM11/28/05
to
peter....@talk21.com writes:

> Others recommended wxPython, PyQt and various derivatives. The trouble
> is there's too much choice!

Agreed, I tried to find /the answer/ some time ago, and I got to the
same conclusion. In addition it is even more difficult to find the
advantages and disadvantages of the different toolkits.

My main reasons for choosing wxpython (but never really try to do
something useful with it) was the native look-and-feel on different
platforms and the many different examples, and the demo application
pysketch.

Unfortunately, even wxpython supports two or three ways of doing
drawings on a canvas, and not that many examples were available for
this.

In addition pyqt should be great, I read. So i have been waiting for
trolltech to release qt4 and just saw that they have. pyqt is not
updated yet.

> One development is that my local public library has, to my surprise,
> managed to locate a copy of 'Python and Tkinter Programming' by J.
> Grayson. I've not read it yet, and an initial flick through
> doesn't look too promising but maybe I am mistaken..

I had the same experience with it. I got more from
http://infohost.nmt.edu/tcc/help/pubs/tkinter.pdf.

--
Brian (remove the sport for mail)
http://www.et.web.mek.dtu.dk/Staff/be/be.html
http://www.rugbyklubben-speed.dk

Cameron Laird

unread,
Nov 29, 2005, 12:08:02 PM11/29/05
to
In article <1133100977....@g44g2000cwa.googlegroups.com>,

There's something about this that bothers me, Kay.

I like the clarity and precision of your explanation. To
avoid trouble is advice worth emphasizing. I applaud your
emphasis on Python's adeptness at co-operating with other
languages.

I think you've left a few things unsaid, though. Others
have pointed out in this thread that, for example, Web
applications are *great* for many GUI requirements. Also,
although toolkit zealots regularly underestimate the
"activation energy" often required to configure a develop-
ment environment, newcomers deserve to know how easy it can
be to start with Tkinter. While it doesn't make for the
slickest MacOS-style applications, it's pedagogically
pertinent that a Mac comes "out of the box" with the ability
to
import Tkinter
Tkinter.Button(Tkinter.Tk(), text = "Push me").pack()
That sort of brevity can encourage beginners in an important
way.

Rod Furey

unread,
Nov 30, 2005, 9:47:41 AM11/30/05
to
peter....@talk21.com wrote:

> Can anyone offer any suggestions as to the least painful way forwards?

I learnt more in half-an-hour with these lectures than days reading the
book and I've been writing programs of all sorts for more than 25 years.

http://wiki.python.org/moin/Intro_to_programming_with_Python_and_Tkinter

Rod (slightly late answer... sorry)

D H

unread,
Dec 23, 2005, 11:50:29 AM12/23/05
to
Kay Schluehr wrote:
> peter....@talk21.com wrote:
>
>>I am trying to learn GUI programming in Python, but have to confess I
>>am finding it difficult.
>
>
> Don't do it if you can prevent it.

What kind of helpful advice is that?

> Conclusion: if you are already familiar with BASIC I would just
> continue writing BASIC apps using VisualBasic dotNet, Windows Forms as
> the underlying GUI toolktit and VisualStudio as IDE. Forget the
> coolness factor of the language. Cool people never care a lot what
> other people think. If you finally want to glue assemblys/controls
> together in Python this is still possible with IronPython or
> Python-dotNet ( which is a CPython binding to the CLR, available at
> Zope.org ).

So you recommend VB.NET on comp.lang.python, and then later publicly
flame me for mentioning boo a year ago, as well as spew FUD about other
languages you don't like. Doesn't the python community already have
enough assholes as it is?

Tim Peters

unread,
Dec 23, 2005, 12:03:02 PM12/23/05
to pytho...@python.org
[D H]
> ...

> Doesn't the python community already have enough assholes as it is?

The Python Software Foundation may well wish to fund a study on that.
Write a proposal! My wild-ass guess is that, same as most other Open
Source communities, we average about one asshole per member. I'd love
to proven wrong, though.

at-my-age-you-need-all-the-evacuation-routes-you-can-get-ly y'rs - tim

Heiko Wundram

unread,
Dec 23, 2005, 12:51:04 PM12/23/05
to
Tim Peters wrote:
> My wild-ass guess is that, same as most other Open
> Source communities, we average [at] about one asshole per member.

Tim, you saved my day. QOTW!

--- Heiko.

Kay Schluehr

unread,
Dec 28, 2005, 1:23:49 PM12/28/05
to

The tone makes the music Doug. The usual crank is obsessed with a few
random ideas and if he does not get enough attention and respect for
them and his own ideosyncratic work he is running around and breathes
fire. The therapeutical advise is usually quite simple: being a little
patient and social but I admit this is very hard for a bloated and
aggrieved ego.

I do not want to repeat my observations and alienations about some
attitudes within the Ruby community in detail. It may suffice to say
that I'm not a Hippie, that I do not consider any PL as "love" and
agree mostly with Bruce Eckels concluding remarks. Nevertheless I find
this new-age / postmodern crossover quite interesting and I do think
that it has certainly it's place in the programming world - no less
than the scientific attitude of e.g. Haskellians or the power
triumphalism of SUN and MS.

0 new messages