+ if generateGetText:
+ gettextStrings += self.FindStringsInNode(resourceDocument.firstChild)
+
+ # now write it all out
+ print >>outputFile, self.templates.FILE_HEADER
+
+ # Note: Technically it is not legal to have anything other
+ # than ascii for class and variable names, but since the user
+ # can create the XML with non-ascii names we'll go ahead and
+ # allow for it here, and then let Python complain about it
+ # later when they try to run the program.
+ classes = u"\n".join(classes)
+ print >>outputFile, classes.encode("UTF-8")
+
+ print >>outputFile, self.templates.INIT_RESOURE_HEADER
+ if embedResources:
+ print >>outputFile, self.templates.PREPARE_MEMFS
+ resources = u"\n".join(resources)
+ print >>outputFile, resources.encode("UTF-8")
+
+ if generateGetText:
+ # These have already been converted to utf-8...
+ gettextStrings = [' _("%s")' % s for s in gettextStrings]
+ gettextStrings = "\n".join(gettextStrings)
+ print >>outputFile, self.templates.GETTEXT_DUMMY_FUNC % gettextStrings
+
+ #-------------------------------------------------------------------
+
+ def MakeGetTextOutput(self, inputFiles, outputFilename):
+ """
+ Just output the gettext strings by themselves, with no other
+ code generation.
+ """
+ outputFile = self._OpenOutputFile(outputFilename)
+ for inFile in inputFiles:
+ resourceDocument = minidom.parse(inFile)
+ resource = resourceDocument.firstChild
+ strings = self.FindStringsInNode(resource)
+ strings = ['_("%s");' % s for s in strings]
+ print >>outputFile, "\n".join(strings)
+
+ #-------------------------------------------------------------------
+
+ def GenerateClasses(self, resourceDocument):
+ outputList = []
+
+ resource = resourceDocument.firstChild
+ topWindows = [e for e in resource.childNodes
+ if e.nodeType == e.ELEMENT_NODE and e.tagName == "object"]
+
+ # Generate a class for each top-window object (Frame, Panel, Dialog, etc.)
+ for topWindow in topWindows:
+ windowClass = topWindow.getAttribute("class")
+ windowClass = re.sub("^wx", "", windowClass)
+ windowName = topWindow.getAttribute("name")