[Tutor] Making Window stay open, Python in Windows

Ivan Van Laningham ivanlan@callware.com
Thu, 03 Feb 2000 17:07:02 -0700


Hi All--

Chris Carpenter wrote:
> 
> Hi Patrick,
> 
> i just started learning Python aswell, and ran into the same problem. I was
> reading a tutorial called "Instant Hacking  Learn how to program with
> Python" by Magnus Lie Hetland  and i used this to stop the window
> dissapearing for a while:
> 
> #put this at the top of your code
> from time import sleep
> 
> #put this at the end of your code, the number in brackets is the seconds the
> program will sleep, thus leaving the window open on the desktop for that
> long
> sleep(30)
> 
> I'm not sure if thisis the best way to do it,(iv'e only been doing the
> python thing for about 4 days)
> But Hey, it worked for me.
> 

It does work, but it's not what you want to do.

You have two easy choices:

1)  Use the interpreter interactively.  Open a DOS box, type "python"
and wait for the ">>>" prompt.  If it says "program not found", then go
to the directory where you have python installed and run it there.  Once
you have the >>> prompt, type your program in.  It will run each line as
it gets to it.

2)  Type your program into a file.  Give the file a .py suffix.  Open
your DOS box and type "python spam.py" (for instance).  Again, if DOS
complains that it can't find python, take your .py file and go to the
directory where python lives, and type "python spam.py" again.

2) is the most common choice, since it saves your program for later use.


I assume that you put your program into a file, and then double-clicked
on it from Windows. You're not ready to do that yet--you need to have
some knowledge of Tkinter before you can do it correctly.

<back-to-the-primordial-ooze>-ly y'rs,
Ivan
----------------------------------------------
Ivan Van Laningham
Callware Technologies, Inc.
ivanlan@callware.com
ivanlan@home.com
http://www.pauahtun.org
See also: 
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
----------------------------------------------