Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Pygame error

  1. #11
    Join Date
    Jun 2007
    Beans
    115
    Distro
    Gutsy Gibbon Testing

    Question SOLVED!!!!! (But I still have a question)

    The file and the image were both on my desktop. I accessed the file by typing in "python" then dragging the file into the terminal. This apparently wasn't a good idea.

    Typing in "cd ~/Desktop, then typing in "python game.py" worked. However, this leaves me with one question: is there anyway do define the full path for the image on any system so when the program is run like how I did originally, it will work. Does anyone know how to do this?

    Thanks,
    yuvlevental

  2. #12
    Join Date
    Jun 2006
    Location
    CT, USA
    Beans
    5,267
    Distro
    Ubuntu 6.10 Edgy

    Re: SOLVED!!!!! (But I still have a question)

    Maybe you want relative path - from current working directory, where you python program lives?

  3. #13
    Join Date
    Jan 2006
    Location
    Philadelphia
    Beans
    4,076
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Pygame error

    well, if you want to load the file from the same directory where the script is located, you'd have to detect where the script is, because otherwise, depending on where you start the script from, the working directory will change. one way to do it would be
    Code:
    import os.path
    import sys
    print os.path.normpath(os.path.join(sys.path[0], sys.argv[0]))
    that will give you the full path to where the script is located. sys.path[0] alone will give you the directory without the scriptname.
    Last edited by nanotube; September 3rd, 2007 at 03:22 AM.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •