Critique and help requested for new programmer
MikeCrowe
mikecrowe at bigfoot.com
Mon Jan 7 16:47:19 EST 2002
Hi folks,
I just completed my first pass at a program that I would like some
comments and critiques of. This is my first "reasonable" python
program, and I'm looking for some inputs on how I could have done it
better. Here's a summary:
ActiveState Python 2.1
wxPython (2.3.1 version -- only version I could get to work with Boa)
XML.DOM used to parse input files (I'm learning XML too, so I put the
datafiles in that format)
Application: Gospel Parallels. Please, no theological commentary on
this subject. I'm strictly interested in inputs in stuff I did way
wrong.
Description: This program opens a window maximized. In the top 3rd
of the window, it displays a tree list (based on wxTreeCtrl) of
different topics. In the bottom 2/3rds, it opens 4 wxHtmlWindows and
displays the specific chapters and verses related to each reference.
The decoding of the references was pretty hairy. Here's how a
reference could be:
Topic Matthew Mark Luke John
200. The beginning of the troubles 24:9-14 13:9-13
21:12-19 14:26;15:21;16:2
I wrote a routine which would use regular expressions to decode any
of the above references. Note: Some references could span chapters
(10:40-11:1). I control that list, so the routine only has to decode
good input (not check for bad input).
I edited the XML tables using Excel XP. That was a very nice
interface to create the datastructures I wanted. Basically, I saved
a spreadsheet with the data arranged in rows and columns. For the
Index, the fields are:
Heading Level Matthew Mark Luke John
For the Bible, there are 4 worksheets:
Matthew Mark Luke John
For each worksheet, each row is a separate chapter, and the verses
are in each column. That gave me the flexibility to enter search
code such as:
workBook = minidom.parse(filename).childNodes
workSheets = workBook[0].getElementsByTagName('ss:Worksheet')
workSheet = workSheets[0].getElementsByTagName('ss:Table')
self.Matthew = workSheet[0].getElementsByTagName('ss:Row')
Now self.Matthew points to the XML structure housing all the
chapters. To drill down to the verse, I only had to:
g = self.Matthew.getElementsByTagName('ss:Data')
text = str(g[verse-1].childNodes[0].data)
g is now the array of verses, and I can drill down to the data with
the text statement.
Specific items I have not been able to solve (yet):
1) wxSplitWindow: Even though my wxPython code calls out the split
window, it doesn't work. I don't think I understand how the splitter
is supposed to work.
2) wxSizer: I need to understand sizers. I would love to have each
of the 4 boxes in the bottom of the screen automatically size to meet
changing window sizes. However, my experiments were futile. Does
wxBoxSizer work with wxHtmlWindows?
This won't be a discussion in this group. I don't want to clutter this with my learning. Send your email address to mikecrowe at bigfoot.com, and I'll send you a zip file of the
distribution.
TIA all volunteers!
Mike
More information about the Python-list
mailing list