| | |
opening a program?
![]() |
OK, I am very new in programming, and I installed python2.5.1 and pygame, and I wrote the hello world programme etc. and I ran it in the python shell. But the problem is, I can't run any python document outside the shell. I tried an example in pygame, and the examples in python, but the same happens. A brief shell opens for a few milliseconds, the closes. Why does this happen and can I correct it?
click here
For others who might run into this problem, a simple solution would be to append the line
at the end of your code.
python Syntax (Toggle Plain Text)
raw_input("Press ENTER to exit")
Last edited by scru; Dec 23rd, 2007 at 9:58 am.
Another way is to use an IDE based editor like DrPython or IDLE that has its own output window.
See:
http://www.daniweb.com/forums/post104865-4.html
See:
http://www.daniweb.com/forums/post104865-4.html
Last edited by Ene Uran; Dec 23rd, 2007 at 11:49 am.
drink her pretty in burbank
•
•
Join Date: Aug 2007
Posts: 8
Reputation:
Solved Threads: 0
To correct this problem you can add this to the end of your program:
If you're like me and don't want to add this to all your programs, I have created a small python program that will automate the process and then ask you if you want to remove the code.
To use it put it in the same directory as your program and run it. Type in the filename of your program (exclude the .py extension, this will be automatically added) and the program will add the code, launch the program and then ask you if you want to remove the code.
This probably won't work with all programs and I'm not to sure if it'll run on Linux or Mac, though I have tried my best to make it as portable as possible.
PythonPauser.py
Python Syntax (Toggle Plain Text)
_pause = raw_input("Press <enter> to continue...")
If you're like me and don't want to add this to all your programs, I have created a small python program that will automate the process and then ask you if you want to remove the code.
To use it put it in the same directory as your program and run it. Type in the filename of your program (exclude the .py extension, this will be automatically added) and the program will add the code, launch the program and then ask you if you want to remove the code.
This probably won't work with all programs and I'm not to sure if it'll run on Linux or Mac, though I have tried my best to make it as portable as possible.
PythonPauser.py
Python Syntax (Toggle Plain Text)
from os import system from os import remove from shutil import copyfile program = raw_input("Which program do you want to open? ") + ".py" progtmp = program + ".tmp" copyfile(program, progtmp) ##Backup original file pause = open(program, "a") pause.write("_pause = raw_input('Press <enter> to continue...')") pause.close() system(program) ##Launch the program restore = raw_input("Do you want to remove the pausing code from the program?(y\n) ") if restore == "y": copyfile(progtmp, program) remove(progtmp) else: pass
Last edited by laseredd; Dec 26th, 2007 at 8:20 pm.
404: Signature not Found.
![]() |
Similar Threads
- C:\Program Files\Common keeps opening on boot (Windows NT / 2000 / XP)
- Running a program (JavaScript / DHTML / AJAX)
- Restarter Program (C#)
- Error when opening a program (was: Help Me!!!!) (Windows NT / 2000 / XP)
- Default program to open *.pdf (Mac Software)
- what exactly is instaling/uninstaling a program. (Windows NT / 2000 / XP)
- IE not workin (Web Browsers)
- Operating Systems assignment (C++)
Other Threads in the Python Forum
- Previous Thread: Open URL
- Next Thread: Daily Task Log File
Views: 2191 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Python
accelerometer application array beginner c++ c/c++ change character cipher class client code command convert count create csv ctypes database def dictionary django dll error examples excel exe extensions fdlib file float format framework ftp function graphics gui homework image images import input library line linux list lists logging loop loops microcontroller mouse mysql mysqldb number numbers output parse parsing path port prime processing program programming py2exe pygame pygtk pyqt python random raw_input recursion recursive redirect remote scrolledtext server socket ssh stdout string strings syntax table terminal text thread threading tkinter transparency tuple tutorial ubuntu unicode variable variables web windows wxpython






