[Tutor] GUI Creation Aide
waynejwerner at gmail.com
Wed Jul 14 14:48:04 CEST 2010
On Wed, Jul 14, 2010 at 7:18 AM, Corey Richardson <kb1pkl at aim.com> wrote:
> Hey tutors! I'm creating a GUI for a program. Really simple. I don't mind
> coding it out, but I was looking into things like Glade and the like. Do you
> recommend those over just coding it out by hand, or should I try Glade (or
> similiar) out? Also, I don't really have a preference for which toolkit I
> use, wx/Tk/GTK, etc.
Honestly it depends on how "pretty" you want it to look. Tkinter is the
ugliest GUI toolkit, but it's the easiest one to create simple GUIs. To
create a window with a button with the text "hello world" that quits when
you push the button:
import Tkinter as tk
root = tk.Tk()
btn = tk.Button(root, text="Hello World", command=root.quit)
And it's as simple as that. There are some fairly powerful widgets, but
nothing quite as advanced as you'll find in other frameworks. However, the
other frameworks do a have the benefit of a lot more power, so it really
comes down to what you want and what you need. If you need a simple GUI with
maybe a list or some text entry and some buttons, and maybe a menu, Tk is
the way to go.
If you want an advanced GUI with all sorts of pretty widgets and drawing
capabilities and bells and whistles, wx or GTK (my personal fave) are all
Of course, it's also my personal opinion that every python programmer should
learn Tkinter - it's a quick and easy way to throw up a GUI - so if you need
to just slap something together, it's right there. Plus it introduces you to
layout managers and callbacks, both of which are super useful programming
GUIs down the road.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor