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)
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
> 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
> 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.
http://www.pygtk.org/pygtk2reference/class-gtkmessagedialog.html
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>
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 :
I recommend getting wxGlade and just fiddling around. You should be
able to produce some interesting GUI's fairly easily.
http://www.fredshack.com/docs/python.html
bs
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
> 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?
>
http://www.fredshack.com/docs/python.html
bs
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
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
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.
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
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.
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
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 ).
You could look at TurboGears.
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
It's a VB-like tool.
But the programming language is not Pyhton :-(
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.
> 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
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.
> 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)
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?
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
Tim, you saved my day. QOTW!
--- Heiko.
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.