wxPython and gnosis.xml.objectify (fwd)

From: David Mertz <voting-project_at_gnosis_dot_cx>
Date: Sat Aug 09 2003 - 13:07:18 CDT

Matt Shomphe <mshomphe@comcast.net> wrote:
|Anand & I made the executive decision to use wxPython for the GUI. So we
|need some way to go from: XML -> wxPython code -> (something like)
|http://home.earthlink.net/~adechert/ballot-mockup3.gif
|Do you think gnosis.objectify is the right way to go? How should we design
|the XML document to make the GUI set up easier?

I have not used wxPython myself; but I am perfectly happy with you and
Anand's decision to go with it. One thing that I would be concerned
with in any GUI libarary chosen is the ability to go fullscreen with the
interface. I.e. voters should not need to worry about window frame
widgets, like minimize/close buttons, scroll bars, etc. Is this
possible to do with wxPython?

I *DO* like gnosis.xml.objectify very much (I wrote it, after all).
Some recent updates have made it better than ever. It is easy to pull
off whatever data you want from the XML ballot description using this
libary. But I think you should design the "ballot description XML DTD"
independently of the library you use to parse it. Don't make
compromises on the XML format to help out the parsing library... it's
the library's job to make what you want to do easy.

That said, gnosis.xml.objectify does this job. I'm sure this simplifies
far too much, but the following gives a feel for possible usage:

    <!-- ballot.xml -->
    <ballot election_date="2004-11-04" state="MA" county="Franklin">
      <election>
        <description>
          Electors for President and Vice-President (a vote for the
          candidate will actually be a vote for their electors
        </description>
        <candidate party="Republican">Abraham Lincoln</candidate>
        <candidate party="Democrat">Harry Truman</candidate>
        <candidate party="Green">Rachel Carson</candidate>
      </election>
      <election>
        ...
      </election>
    </ballot>

    #-- Ballot_parser.py -------------------------------------------
    from gnosis.xml.objectify import make_instance
    ballot = make_instance('ballot.xml')
    date = ballot.election_date
    state = ballot.state
    county = ballot.county
    for slot, election in enumerate(ballot.election):
        wx_in_position_display(slot, election.desciption.PCDATA)
        for candidate in election.candidate:
            wx_next_candidate(slot, candidate.PCDATA, party=candidate.party)

Obviously, in real life, there will be more data involved, and the
formatting rules might be move complicated. But getting at the ballot
data is just like accessing it in a native Python object (you can forget
about the XML futziness altogether after the one 'make_instance()' line.

Yours, David...

--
mertz@  | The specter of free information is haunting the `Net!  All the
gnosis  | powers of IP- and crypto-tyranny have entered into an unholy
.cx     | alliance...ideas have nothing to lose but their chains.  Unite
        | against "intellectual property" and anti-privacy regimes!
-------------------------------------------------------------------------
==================================================================
= The content of this message, with the exception of any external 
= quotations under fair use, are released to the Public Domain    
==================================================================
Received on Sun Aug 31 23:17:04 2003

This archive was generated by hypermail 2.1.8 : Sun Aug 31 2003 - 23:17:17 CDT