Python GUI

Phlip phlip_cpp at yahoo.com
Thu Jun 13 01:07:31 EDT 2002


H. Safarzadeh wrote:

> -Tkinter: A nice simple lib, but really simple! It dosn't have enough
> widgets, and I do not like its look in addition!

Look closer.

The other ones you listed are fine, and you might end up productively going 
with them, but do not judge Tkinter based only on its lone /tkinter page on 
the python.org site.

Firstly, you probably overlooked Python MegaWidgets. Tkinter is not simple, 
it's primitive. That means you must assemble it to get things like a list 
box WITH a scrollbar. Pmw puts together all the pieces into a fat framework 
with splitter bars, canned dialog boxes, combo boxes, spinners, sliders, 
formatted entry fields; the works. And because it comes with a framework 
for this assembly, new assemblages are just an extension away.

Secondly, whenever anyone thinks of a new kind of canvas, such as 
Visualization Toolkit, the first thing they do is make sure it bonds with 
Tcl/Tk. Hence the second thing it bonds with is Tkinter. Search the web for 
these Widgets; they are all over the place. I have found several for flat 
charting (including Blt), and for R3 and R4 presentations like OpenGL.

Thirdly, Tkinter's Canvas widget is essentially a mini-UI kit within a kit. 
You can float a wide number of kinds of graphic objects (shapes, images, 
lines, text, etc.), all represented in memory as objects, not pixels. You 
can bind UI events directly to these objects instead of perform manual hit 
detection outside the black box. They come with a full set of properties so 
you don't need to manage their state and representation for them. And you 
can float primitive windows >and< other Tkinter widgets inside the canvas, 
down among the graphic primitives. Hence you can roll elaborate 
super-widgets yourself with very few lines of code. Just last week, over a 
couple of hours, I implemented visual feedback (a drop shadow) under 
graphics that were clickable, then granted the user the ability to click 
and drag these graphics around, with a bungee line connecting dynamically 
back to their origin. This canvas gave me all that in a very few lines of 
code, and prevented me from wasting many days performing primitive graphic 
manipulations within a hand-made framework. Just because other libraries 
make rolling your own widgets hard don't look at raw Tkinter's low widget 
count as any sign of weakness; it is in fact a strength.

A very nice example of the Canvas in action is TreeBox.py by Arpad Kiss, 
featured here:

        http://c2.com/cgi/wiki?PyUnitTestBrowser

Fourth, Tkinter has been around a very long time, and any UI question you 
could think to ask (such as idle timer functions, multi-level callbacks, 
elaborate key chord detection, mousewheel support) has been added to the 
system.

Put them all together, and you have a >lot< of widgets, a lot of abilities 
under the hood, and a lot of potential for very facile coding.

End of zealotry. The next time someone floats this question I'l 
passionately recommend Fltk or PyAmulet or something.

-- 
  Phlip
       http://www.greencheese.org/LucidScheming
  --  In business always remember:
      The customer is always funny!  --




More information about the Python-list mailing list