Sign in to follow this  
velentry

Python

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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"?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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