NumTut view of greece

G

Gary Wessle

Hi

not sure if this would be the right place to ask this question!
using the shell prompt
:~$ python
Python 2.3.5 (#2, Mar 6 2006, 10:12:24)
[GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.shows a photo of the street in a tk window.

but if I have this file
**************** tut.py ****************
#!/usr/bin/env python
import Numeric
from NumTut import *
view(greece)
print "done"
****************************************************************
and then type
$ ./tut.py
done
$
and not tk view of greece.

thanks
 
G

Gary Herron

Gary said:
Hi

not sure if this would be the right place to ask this question!
using the shell prompt
:~$ python
Python 2.3.5 (#2, Mar 6 2006, 10:12:24)
[GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

shows a photo of the street in a tk window.

but if I have this file
**************** tut.py ****************
#!/usr/bin/env python
import Numeric
from NumTut import *
view(greece)
print "done"
****************************************************************
and then type
$ ./tut.py
done
$
and not tk view of greece.
That's because, as soon as the program quits, the view window is removed.

In your interactive example, the view command opens the window, and then
immediately starts waiting for you to type the next command. Python is
still running and so the view window stays up.

In the non-interactive case, as soon as the view command executes,
Python immediately goes to the next line, does the print, then exits.
The view command, which was busily preparing to show your picture is
shut down when python exits before it had enough time to open the
window. (It was trying -- it just didn't have enough time.)

If you don't want the program to quit that quickly, you need to put in
something to keep it from running off the bottom and exiting. I'd
suggest something like this after the view line:

raw_input("Type ENTER when done viewing: ")

Gary Herron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top