GUI programming

Mark 'Kamikaze' Hughes kamikaze at kuoi.asui.uidaho.edu
Wed Apr 3 21:48:37 EST 2002


Fri, 29 Mar 2002 17:39:14 -0800, Umesh Persad <upersad at tstt.net.tt> spake:
> felds and buttons. I see there are many GUI toolkits
> available. I am wondering which one should I use
> (tkinter, wxpython?) that will be simple enough
> to get me up and running qiuckly. Also are there
> any examples that I can look at? 

  If you want A) ease of installation on all platforms, and B) a really
good book on the subject, there is only one serious choice: Tkinter.
It's the standard, it's easy to work with, and John Grayson's book
_Python and Tkinter Programming_ is superb.  I've run my Umbra game
<http://kuoi.asui.uidaho.edu/~kamikaze/Umbra/> on every platform I could
get my hands on (Windows, Linux, Mac, FreeBSD, HP-UX, and Solaris), and
it just works (though I had to tweak the font sizes on Windows but not
on other platforms, I dunno why).

  If you're willing to accept some installation hassles on some
machines, PyQt is a superior GUI toolkit (Qt uses events and listeners,
which Qt call "signals" and "slots" just to be different, rather than
callbacks, and has better components), and the book _GUI Programming
with Python: QT Edition_ <http://www.opendocspublishing.com/pyqt/> seems
to be quite good so far (I'm still in the middle of reading it).

  wxPython has a handful of fanatical believers, but I was never able to
get it working on my Linux box, and the Mac and non-Linux Unix support
is basically nil.  I can't recommend it for serious use.

  The fourth option is PyGame <http://www.pygame.org/>, which is based
on SDL, is fairly portable and easy to install, and is nigh-perfect for
developing games in.  However, the documentation is not as good as it
should be, it has a fairly non-Pythonic interface, and it's not a good
general-purpose GUI solution.

  For your project in particular, you could get by just fine with
Tkinter, but you may want to take a look at PyGame.

> Also, if any one is familiar with Tkinter,
> how do I put up a window with a size
> that I want? Also how do I place a canvas
> on the window at a predefined size?

  Windows can be positioned with code like:
win.geometry("+%d+%d" % (x, y) )
  I'm sure there are other ways, but that's how I do it.  If you want to
resize it, use:
win.geometry("%dx%d+%d+%d" % (w, h, x, y) )

  Positioning a canvas, OTOH, I don't recall.  I know there are ways to
do absolute positioning, but I almost always use the packer or grid
layout managers.  I think this is covered in Grayson's book.

-- 
 <a href="http://kuoi.asui.uidaho.edu/~kamikaze/"> Mark Hughes </a>
"No one is safe.  We will print no letters to the editor.  We will give no
space to opposing points of view.  They are wrong.  The Underground Grammarian
is at war and will give the enemy nothing but battle." -TUG, v1n1



More information about the Python-list mailing list