[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Help with the 3rd Lecture, first tutorial




Yes!

    For the path function inside the program is only looking at the file in the directory directly below the python25. Thus it will always fail unless he changes the path to the file directly. Kevin when you load the Python25 you have placed the path as that location, in the Python25. 

    I set the file path to change in the batch files so when you load Python25 you also have that directory path at the moment of loading. Now if you want to do this with your way of doing then you will just make the batch file to do it but leave out the %1.py for that loads your command line data...%1 %2 %3...

Or like this inside your batch file:
 c:\python25\examples\python25 
Making batch file for example directory:
type: copy con: xpy.bat <enter>
c:\python25\examples\python25 <enter>
ctrlz <enter>
     1/file copied!

    The path is c:\python25\examples\data when the program looks for it. Not in the program files directory when doing the example as is!
Or: you can change the os.path to place the c:\program files\data to find it, but that means do not use os.path.

    So, do what you wish but try and keep all work files inside the directory consistently. In other words while testing keep then beneath the python directory or everything in the program files. But for safety sake and viruses it may be better to have something away from the c drive. Only a thought and if you do have a multiple drive system.

        Bruce

----- Original Message ----- 
From: "Ethan Glasser-Camp" <glasse@xxxxxxxxxx>
Sent: Wednesday, October 31, 2007 8:44 PM
Subject: Re: [pygame] Help with the 3rd Lecture, first tutorial


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

kevin hayes wrote:
> (1) I run python by c:\Python25>Python <Enter>
> 
> Once in the interpreter, I can import the pygame modules, initialize
> Python, make a window, but when I try to set the caption it won't work.
> I did get it to work in the GUI, however.
>  
> pygame.display.set_caption('Monkey Fever')
> 
> (2) C:\Program Files\examples\data\chimp.bmp   "Is the path to the image"
> 
> When trying to load the image with:
> 
> monkey_head_file_name = 
> os.path.join("data","chimp.bmp")
>>>> print monkey_head_file_name                             "Creating a relative Path"
> 
> data\chimp.bmp
> 
> monkey_surface = pygame.image.load(monkey_head_file_name)    "From the tutorial...trying to load the image"

Seems to me that the tutorial expects you to be running python from
inside the c:\Program Files\examples directory. Lukasz has tried to
explain how to change directory to that directory and then run Python,
and RR4CLB has put together some batch scripts for you to run Python
from that directory. You could also use the os.chdir function, as
follows (on a Linux system):

>>> import os
>>> os.getcwd()
'/home/ethan'
>>> os.chdir("/home/ethan/tests/")
>>> os.getcwd()
'/home/ethan/tests'

If you chdir() to 'c:\Program Files\examples', you should be able to
run the examples directly as written.

Hope this helps!

Ethan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKS91hRlgoLPrRPwRAsTUAJ9da7op3jDVOom0vHNJxlDsQS0EVQCgjLAo
bGHnlPOsO+VV6WuuSqX4L4I=
=MPsQ
-----END PGP SIGNATURE-----


-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.15/1101 - Release Date: 10/31/2007 10:06 AM