Sign in to follow this  
Zaku

saving python

Recommended Posts

how do you save things that you program in the idle into programs where you just click on the icon and the program runs?

Share this post


Link to post
Share on other sites
http://www.python.org/infogami-faq/programming/how-can-i-create-a-stand-alone-binary-from-a-python-script/

The above link may help.

I've used py2exe and had it work nicely.

Share this post


Link to post
Share on other sites
hmmm i downloaded and installed p2exe, now what do i have to do?



also, where do i ultimately write games? in the idle?

Share this post


Link to post
Share on other sites
Yeah, at least you can (and alot of people do) write them in IDLE. There's other places too (note pad works just fine, too, but doesn't have highlighting, debugging, and other niceties).

This is a nice tutorial on how to use py2exe. There's plenty others out there, too.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zaku
do u need pygame to make games?


For making basic games, then yes.

But if you want to go into core gaming, you need to interface DirectX and Python or OpenGL and Python.

This is how games like Severance: Blade of Darkness and Freedom Force have been made.

Hope it helped, bye.

Share this post


Link to post
Share on other sites
are directx and opengl both engines? are they good at making 2d games? cause im looking at that zak thing.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zaku
are directx and opengl both engines? are they good at making 2d games? cause im looking at that zak thing.


DirectX and OpenGL are API's (application programmign interfaces) which form the basis of all game engines (like OGRE, IRRLICHT etc.)

Yes you can make 2d as well as 3D games using them but if you are just starting out making games using an external library would be better.

Try to google that and i am sure you will get the help you need.

Share this post


Link to post
Share on other sites
Quote:
Original post by NotAYakk
http://www.python.org/infogami-faq/programming/how-can-i-create-a-stand-alone-binary-from-a-python-script/

The above link may help.

I've used py2exe and had it work nicely.


still finding that a bit confusing...

can i get an explanation easier than that?

[Edited by - Zaku on October 1, 2006 3:28:58 PM]

Share this post


Link to post
Share on other sites
Don't type your programs into the first IDLE window you see. Instead, open a new window from the menu. Then you can use the 'Save' function in that window.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kylotan
Don't type your programs into the first IDLE window you see. Instead, open a new window from the menu. Then you can use the 'Save' function in that window.


Be sure to save it in the "filename.py" format before you start, so the color coding is visible.

Share this post


Link to post
Share on other sites
hmmm..... i did what you guys told me to do, and now the icon whenener i save is now a snake thingie, so im getting there....
however, there is still a problem. whenever i run it, this command thing flashed for like half a second then closed and thats all that happened. is there an error in the code?
the code was:
print "blabla"

Share this post


Link to post
Share on other sites
Quote:
Original post by Zaku
whenever i run it, this command thing flashed for like half a second then closed and thats all that happened. is there an error in the code?


That is normal behavior for a console application run from Windows. Not a Python thing it happens no matter what language the app is programmed in. For development purposes, people sometimes will put a pausing command at the end of the program that waits for a keypress before ending. In Python this could be a call to raw_input. But be warned that pausing is NOT normal program behavior so when the time comes that you want to give your programs to other people you must not do that. People generally don't want a program hanging around when it has finished doing its work.

Share this post


Link to post
Share on other sites
It probably did, but then it closed to fast to see it. Put in a pause and see if the output is there. Better yet, run the application from a console (command prompt) for now. To do that just open the Windows command prompt, cd into the directory your scipt is in, then run "python myscript.py". This makes it easier to run the program with various options, and to see some output when your program crashes horribly (which is will do many times while you are starting to learn ... don't get discouraged).

Share this post


Link to post
Share on other sites
Yeah it's usually best to run from the command shell or the interactive interpreter. Even with a pause at the end of your script, if an exception is thrown before that it will again quickly close before you can read the error message. You can run a script from the interactive interpreter by typing execfile('whatever.py').

Share this post


Link to post
Share on other sites
Quote:
Original post by Hollower
Yeah it's usually best to run from the command shell or the interactive interpreter. Even with a pause at the end of your script, if an exception is thrown before that it will again quickly close before you can read the error message. You can run a script from the interactive interpreter by typing execfile('whatever.py').


is it harder to save your program in a way that a computer challenged person could just click on the icon and run the program without the need of having python installed (instead of using the command)?

[Edited by - Zaku on October 3, 2006 3:00:38 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Zaku
is it harder to save your program in a way that a computer challenged person could just click on the icon and run the program (instead of using the command)?


No, you had that part working - you simply double-click on the .py file. Trust us it DID work even if it closed too fast for you to see the output. Our advice has been for you the programmer. For other people to use a program you wrote they will simply click on the icon. If it is a console app and doesn't have any kind of menu or prompt that waits for input then it should close as soon as it reaches the end. It is also possible to write GUI (Windows) applications in Python but that is a more complex subject.

Share this post


Link to post
Share on other sites
oh i see what you are saying. ill try to make it wait for output, and see if it stays open


EDIT: *GASP* it finally works! thx guys =)!

[Edited by - Zaku on October 3, 2006 4:32:00 PM]

Share this post


Link to post
Share on other sites
Don't worry about py2exe, yet. Focus on playing around with raw text scripts (i.e. the .py files you've already been told about), first. When you're ready to distribute your games to others, use py2exe to combine all your .py files into a single EXE. This will allow people to run your game without installing Python and whatever libraries you used (i.e. PyGame, PyOpenGL, Numeric, etc.).

If you start getting tired of using notepad and the command line to run your scripts, you might want to take a look at a better IDE like Eclipse. It is free to download, but it takes some time to learn. You could also use TextPad, which costs $30 but offers an unlimited trial period. TextPad allows you to configure external tools (like python.exe), so you can run your Python scripts and not have the console close when the script is finished running.

Good luck!

- Mike

Share this post


Link to post
Share on other sites
Quote:
Original post by Zaku
is it harder to save your program in a way that a computer challenged person could just click on the icon and run the program without the need of having python installed (instead of using the command)?


You could also try making the following batch file (whatever.bat):


python whatever.py
pause

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this