Skip to main content
GameDev.net gamedev.net
🔒 Locked

Python

Started by velentry Jul 5, 2008 at 9:51 AM 9 replies 1.4k views
Original Post
velentry
velentry
Hi it's me Vel, i wasn't sure where to post this since there isn't a python section so i was wandering if anyone may know the reason to why everytime i try to run the actual display window (not the shell but the window that you load inside the shell) it crashes. Regards Vel
oler1s
oler1s
Eh? This is an incredibly vague question. If you want actual help, you need to give us real details.
velentry
velentry
errmmm there isn't a error code i can give or anything but if for example i made a new black window and changed its size using the python script and went to execute the script, the new window would crash well just not work.
mrbastard
mrbastard
I suggest posting code.

Python itself knows nothing about windows and their size, so you'll have to be more specific. Are you using a GUI library inside Python?

Am I right in interpreting "crash well just not work" as "the window closes"?
[size="1"]
doctorsixstring
doctorsixstring
Are you running Python from the command line? Or are you using IDLE or some other IDE?
velentry
velentry
i am using the GUI library and the code i am using is off a tutorial heres the code though well the bit that i can get so far before it opens the pygame window that crashes

>>> import sys, pygame
>>> pygame.init()
(6, 0)

this tells it where to import the files from right?

>>> size = width, height = 320, 240
>>> speed = [2, 2]
>>> black = 0, 0, 0

this sets the height and width of the window along with the speed it will move at?
>>>
>>> screen = pygame.display.set_mode(size)
>>>

this brings up the window?

im just want to check at the same time that i understand what i'm writing

Regards Vel
velentry
velentry
sorry another question how do i get python to find a saved image i have the code but i don't know where to save the picture in order for it to find it

(sorry edit i just didn't specify the place where the picture was sorry)
doctorsixstring
doctorsixstring
Your code worked fine for me in IDLE. However, closing the window crashed IDLE. This is a known "issue" with IDLE and Pygame: The pygame screen does not exit correctly in IDLE. Is that the crash you're referring to?

I'd recommend saving your code to a text file with a .py extension and running it with the python interpreter. If you're using Windows, simply double-click on your .py file to run it.

For your second question, Python file operations are relative to the current directory, which is usually the directory where your script is located.
velentry
velentry
ooo yer that is the error i get and it resets the entire script so that you have to begin from the beginning.

Thanks for the help
Vel
Cherub of Death
Cherub of Death
Hey I also have question. I was wondering after you save your program as .py can you send it to a friend? I am not sure that someone without python can open a .py file, so how can others try a program?
Luctus
Luctus
Quote:
Original post by Cherub of Death
Hey I also have question. I was wondering after you save your program as .py can you send it to a friend? I am not sure that someone without python can open a .py file, so how can others try a program?
No, to run a .py file, one needs to have the python interpreter with environment installed. However, there are utils for packaging python source files into distributable applications. One such is py2exe which creates a small windows exe-file that loads a python-dll and executes the packaged python source.
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.