From: Alex T. <al...@tw...> - 2005-04-09 20:08:38
|
I said: > Sells, Fred wrote: > >> I realize that the PythonCard resouce structure is a straight forward >> combination of {} and []. >> >> before I reinvent the wheel, has anyone written a simple script to print >> this out (text or html) in a form more human (well programmer >> actually ;) >> readable form. I find myself going back to check resource names too >> frequently and would like a quick reference. >> >> > Haven't felt a need to do that. But if I did, what I'd probably do is add some code to the "saveFile" function in the resourceEditor, so that each time I saved the resource file, I also saved the equivalent nice, readable version. I wrote a couple of lines of code to do a very basic version of that - here's a context diff ... (it's the same little code fragment inserted in two places). > *** resourceEditor.py Thu Sep 30 15:16:24 2004 > --- ../myresourceEditor/resourceEditor.py Sat Apr 9 21:04:19 2005 > *************** > *** 828,833 **** > --- 828,845 ---- > f.close() > self.documentChanged = False > self.fileHistory.AddFileToHistory(self.filename) > + > + f = open(self.filename+'txt', 'w') > + desc = '' > + for w in self.components.order: > + if w not in self.sizingHandleNames: > + aWidget = self.components[w] > + desc += "%s: %s %s \n" % > (aWidget.__class__.__name__, aWidget.name, aWidget.position) > + f.write(desc) > + f.close() > + > + > + > return True > except Exception, e: > message = 'The resource file could not be saved.\n' > + str( e ) > *************** > *** 961,966 **** > --- 973,987 ---- > f.close() > self.filename = path > self.documentChanged = False > + f = open(self.filename+'txt', 'w') > + desc = '' > + for w in self.components.order: > + if w not in self.sizingHandleNames: > + aWidget = self.components[w] > + desc += "%s: %s %s \n" % > (aWidget.__class__.__name__, aWidget.name, aWidget.position) > + f.write(desc) > + f.close() > + > return True > except: > return False this saves a file such as "name.rsrc.pytxt" with the readable version. -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 07/04/2005 |