On 8/14/07, Jay Loden <[EMAIL PROTECTED]> wrote: > > XML is first and foremost a machine-parseable language, and a human-readable > one second ;) I don't think this is particularly hard to read, but then I > work with XML configuration files on a daily basis at work, so I may just be > a terrible person to ask... > > I'm not sure I agree that you're not using XML as it was intended; you're > mixing data and presentation, but it's still a document containing data. > That's what XHTML is, and what the XML document definitions like OOXML are > all about. Anyway, that's neither here nor there. My question would be a much > simpler "why is this XML?". > > XML makes sense when you need a structured document, and sometimes that makes > sense for configuration options or defining a structure, but it's not clear > why you'd need it here. Is this something you're intending to make editable > by the end user? If you're willing to replace it with Python scripts instead > of XML documents, it sounds like maybe you're not worried about letting users > edit the menus. If so, why not code the menus direct into the main C++ code? > This would be faster, unless you need to frequently edit these menus. > > I think the best thing to do would be to take a step back and ask what it is > that you're trying to do as the end result. What are your requirements; can > you expect that Python will be installed already? Is the choice between > parsing XML once with C++ or having to ship a Python interpreter with > associated overhead? Once you have a set of requirements and determine what's > most important to you it should make it easier to pick a solution. For > instance, on a mobile device, you might simply not have the spare cycles that > embedding a python interpreter would require versus a lightweight lib like > TinyXML. Similarly, you'd have to ask yourself if the data is always static, > or if you have a need for dynamic content (i.e. embedded scripting) within > the menu definition. > > -Jay >
Well, Ideally the python script would have a series of callback methods that are triggered when specific predefined events occur in that menu. For example, when the user presses the LEFT key, a callback should be executed in the python script to perform various tasks. So you'd do something like: def OnKeyLeft(): # Do something here... pass However, I think the root of the problem is that I'm editing text files directly to modify the look and feel of menus. Ideally, I'd have a tool that allows a user to visually create a menu by interactively creating controls and assigning them properties through a GUI interface. However, in my specific case I was unable to make a tool due to time restrictions. I could, at the very least, use wxPython to make this tool, which would output menu definitions in XML (which will be non-human readable or editable), or perhaps even binary for quicker parsing by the game. -- http://mail.python.org/mailman/listinfo/python-list