[Tutor] Well...

Michael Powe michael@trollope.org
Fri Dec 20 10:17:01 2002


On Thu, Dec 19, 2002 at 11:59:07PM -0500, GREENDAY31087@aol.com wrote:
> I'm just learning about python and programming in general so bear with me. 
> 
> Some lame questions that should be easy for everyone else...
> 
> -Could someone explain why GUI toolkits such as Tkinter are needed and used?

i think the short answer is, so you don't have to reinvent the wheel.
a gui toolkit is about controlling the cursor on the screen.  keeping
track of the location of the cursor, moving it, setting and changing
the rgb of the screen pixels, capturing the click of a mouse,
associating user input with variables, based on screen location of the
input, &c are non-trivial exercises.  you could learn how to do this
(in C and assembler) and do it every time you wrote a program ... or
you could use a library written by someone else, who has done all that
work and put it together in a package that can be reused by anyone
wanting to create an interface.

> -Why is it that when a program finishes up, it immediately quits? Some 
> programs have outcomes I'd like to view...How can I make it pause (like in 
> DOS)?

print to screen or to file; or write a simple pause function with sleep.

note, however, that if you are running in an xterm, you may encounter a
problem with printing to screen due to the way xterms are constructed.
i'm not sure exactly how or why this is done (though i have seen the explanation,
i just can't remember it) -- but when you call some programs in an xterm window,
it actually writes a second window over the top of the original and writes
your program output to that window.   then when your program exits, the
second window exits also and you are returned to the original.  the most
obvious example of this behavior is reading a manpage.  i saw tom dickey
post an explanation of this behavior once to a newsgroup but in my aged 
decrepitude, i can't remember it.  ;-(

as to why a program quits immediately, well i think that part is
probably obvious -- a program only does what you tell it to do.  the
problems arise in the split between what you told it, what you thought
you told it, and what you actually wanted.  ;-)

mp