protect resources (images) within a pygame-program

Mike C. Fletcher mcfletch at rogers.com
Thu Oct 21 21:14:33 CEST 2004


Using ResourcePackage may help you.

Basically this provides a sub-package of your project in which you dump 
your resources.  You then use mypackage.resources.filename_ext.data as 
the source for your files.  This allows your data-files to survive being 
py2exe'd or zipped just as if they were regular Python modules (since 
they are python modules).  However, if you users want to edit them, they 
need merely download ResourcePackage (and get a version of your package 
that is stored in the filesystem (i.e. unzip your package)) and edit the 
source files.  If you want to just pack one copy in your game, then you 
can pack the .py files and let the users extract them using 
ResourcePackage's included scripts.

That is:

unzip yourproject
extract.py -f yourproject.resourcePackageName

To get the files in editable format.

If you mean, instead, that you want to have the files stored in some 
commonly accessible location, rather than in the program files 
hierarchy.  You can store the files in the user's Application Data 
folder (well, in a sub-directory of that).

http://resourcepackage.sourceforge.net/

HTH,
Mike

benjamin wrote:

>A pygame/python game resource question
>######################################
>I wander whether there is any possibility to compile a bunch of
>resources for a program, like images and soundfiles into a package
>like, let´s say "game.dat", so they do´t fly around in the programs
>folder und can be edited by everyone.
>Hope somebody can help me.
>  
>
________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com




More information about the Python-list mailing list