Search code examples
pythonosx-snow-leopardpy2app

Bundle Text file in py2app Application (python)


I recently learned Python (2.7) and have been making some simple board games with AIs and such as practice. I am currently making an intelligent hangman game which necessitates the inclusion of a dictionary file. (I have a text file which has a new word on each line). I used py2app successfully for other stuff such as this: connect-four.zzl.org but unfortunately, it doesn't seem to include my text file when I run py2app for my new hangman program. Can anyone help me figure out how to include this file so that the program can be distributed like the connect four game I linked to?

Thank You very much. (I am running OS X 10.7 and can provide any other necessary info if necessary)


Solution

  • Specify a resources key in your options that contains a list of resources to include. This will be the current directory when your app runs

    options = { "resources": ["myfile.txt"] }

    http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html#option-reference

    If you use the resources flag with py2applet it will creates that key