Services |
PythonCard on the MacI needed to get PythonCard working on my mac for a course I'm teaching with Warren and Carter Sande's book, Hello World! By changing the model.py file that comes with PythonCard 0.8.2, I was able to run resourceEditor.py from a Terminal window and complete the TempGUI project in chapter 20 of the book. If you'd like to see if this change will work for you, download my model.py. Do a search for model.py on your hard drive. Rename the original (I renamed mine to model.original.py) in case you need it later. Then copy the downloaded model.py to the same directory. The directory name will be something like: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PythonCard/ I am not liable if your computer blows up while you're trying to implement this change. Don't forget to always make backups before attempting stuff like this. For the Curious HackerBelow are the changes I made. I'm relatively new to Python, and brand new to PythonCard, so if you have a cleaner solution that works on your mac, please shoot me an email. My problem occurred while running:
I got the following error running resourceEditor.py out of iTerm: TJ-Leones-MacBook-Pro:resourceEditor tjleone$ python resourceEditor.py no resource file for /Library/Frameworks/Python.framework/Versions/2.6/lib/pytho n2.6/site-packages/PythonCard/tools/resourceEditor/propertyEditor Traceback (most recent call last): File "/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.6/site-packages/wx -2.8-mac-unicode/wx/_core.py", line 14669, in <lambda> lambda event: event.callable(*event.args, **event.kw) ) File "resourceEditor.py", line 138, in on_initialize self.propertyEditorWindow = model.childWindow(self, PropertyEditor) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa ckages/PythonCard/model.py", line 213, in childWindow rsrc = resource.ResourceFile(filename).getResource() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa ckages/PythonCard/resource.py", line 45, in __init__ self.dictionary = util.readAndEvalFile(rsrcFileName) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pa ckages/PythonCard/util.py", line 39, in readAndEvalFile f = open(filename) TypeError: coercing to Unicode: need string or buffer, NoneType found I traced the error back to the inability to find propertyEditor.py in PythonCard/tools/resourceEditor/modules/. I was afraid to move files around, so I added a couple of conditions to the internationalResourceName() function in model.py instead. Here's the original version: def internationalResourceName(base): ... # AGT 2005-05-17 Detect missing resource file, give some warning; no clean recovery possible. filename = None for f in filenames: if os.path.exists(f): filename = f break if not filename: print "no resource file for", base return filename Here's my change: def internationalResourceName(base): ... # AGT 2005-05-17 Detect missing resource file, give some warning; no clean recovery possible. filename = None for f in filenames: if os.path.exists(f): filename = f break if not filename: for f in filenames: ## A workaround to find files in the modules directory --TJ fn = os.path.join(os.path.dirname(f), "modules", os.path.basename(f)) if os.path.exists(fn): filename = fn break if not filename: print "no resource file for", base return filename |