Python script for mobile platforms -- suggested?

Robert Dailey rcdailey at gmail.com
Tue Aug 14 11:42:00 EDT 2007


Hi Jay,

I apologize for not having been detailed enough. Right now I'm using a C++
library known as TinyXML to parse my XML files. When a menu is to be
displayed, the XML is parsed and the appropriate images, text, etc that will
display on the menu is loaded based on the data in that XML. Note that the
XML parsing happens before the menu is drawn and only happens once per menu
as to avoid performance overhead during the menu drawing.

For example, to create a menu that has an image in the center of the screen,
the XML would be this:

<Page>
    <Frame type="Root">
        <Frame type="Image" value="MyImage.png">
            <Origin point="CENTER"/>
            <Justification point="CENTER"/>
        </Frame>
    </Frame>
</Page>

The "Origin" and "Justification" elements act sort of like function calls,
and the "Frame" element defines an "Object" kind of. Each Frame is a visual
element in the Menu.

I'm not sure if you'll agree or not, but even in this simple example it's
very hard to read just given the nature of the XML syntax. Secondly, I'm not
using XML as it was intended to be used. I'm using it as a script instead of
a representation of data. Most of the real menus are 600+ lines of XML much
like above, however it is not nearly as simplistic. I will paste a real
example of a menu below this email for those curious to look at it.

I haven't decided on what the Python version of the example above would look
like, that would probably happen sometime after I decided to go with Python
for a menu scripting replacement (If I do, that is). I might mix XML and
Python much like World of Warcraft mixes XML with LUA script. Again, this
all depends on design. The important points I wanted to get across is that
the Python script wont' be executed past the construction of a menu. The
Python/XML script would be simply there to allow the game to create the menu
and other important things.

I hope I've given enough examples and details. If I haven't, please let me
know and I'll answer any questions you may have. Thanks for following up.

On 8/13/07, Jay Loden <python at jayloden.com> wrote:
>
> Robert Dailey wrote:
> >     I'm currently developing a game for a cell phone. The game has a GUI
> >     system that's currently using XML to define the individual menus.
> >     Basically this means that for every single menu the user goes to, it
> >     loads and parses an XML file. Would using Python Script instead of
> >     XML be a reasonable replacement, or would it be even slower? I've
> >     read various articles online but I'm still curious to hear what
> >     everyone has to say here.
>
> A number of questions come to mind...for starters:
>
> 1) What is parsing the XML now? C code? Python?
> 2) What is the proposed python script supposed to do when they load the
> menu? without knowing that or seeing some sample code or details, that's an
> impossible question to answer, since an arbitrary Python script might take
> milliseconds, seconds, hours, or days to complete running.
>
> It might help if you give a concrete example (code is always welcome!) and
> explained exactly what the options are that you're considering and why. Then
> the folks on the list can try to give you a rough estimate or possibly
> suggest alternative methods you may not have considered.
>
> -Jay
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070814/0e4dfa66/attachment.html>


More information about the Python-list mailing list