Re: Python script for mobile platforms -- suggested?

2007-10-19 Thread Robert Dailey
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


Re: Python script for mobile platforms -- suggested?

2007-08-14 Thread Robert Dailey
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 [EMAIL PROTECTED] 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

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python script for mobile platforms -- suggested?

2007-08-14 Thread Jay Loden
Robert Dailey wrote:
 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.

TinyXML is pretty fast, and I'd wager to say that even without knowing what the 
Python code would be that replaces the XML, my guess is you'll take a 
performance (mem/cpu or both) hit, if for no other reason than introducing the 
Python interpreter overhead.

 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.

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 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 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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python script for mobile platforms -- suggested?

2007-08-13 Thread Robert Dailey
*bump*

On 8/12/07, Robert Dailey [EMAIL PROTECTED] wrote:

 Hi,

 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.

 Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python script for mobile platforms -- suggested?

2007-08-13 Thread Jay Loden
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
-- 
http://mail.python.org/mailman/listinfo/python-list


Python script for mobile platforms -- suggested?

2007-08-12 Thread Robert Dailey
Hi,

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.

Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list