My little project is coming along well, and should be ready to share "real soon now". I went off on a wild goose chase scanning the XRCed source for code I could re-cycle, but didn't find anything. The module wx.tools.XRCed.plugins.core has a lot of stuff I could've used, but it wasn't in a format that I could easily extract and re-cycle.
So, I've written the following stand-alone module. Other people's opinions on this data format would be appreciated.
'''
The file wxWidgets/trunk/docs/tech/tn0014.txt purports to describe the
rules for creating and interpreting XRC files. This module attempts
implement those rules in the context of generating XRC for a live wxApp.
'''
# These are value formatters; they turn values into strings.
# *** Don't mess with the doc-strings. ***
# The class_name argument is only used by the as_style formatter to find
# the correct collection of styles for a value.
def as_boolean(class_name, value):
'Boolean'
return '%r' % value
def as_colour(class_name, value):
'Colour'
return '#%02X%02X%02X' % (value.Red(), value.Green(), value.Blue())
[...]
# This table maps XML tags to a getter-method, a formatter, and a
# default value, as listed in tn0014.txt:
attribute_info = {
'accel': ('GetAccel', None, ""),
'bg': ('GetBackgroundColour', as_colour, None),
'bitmap': ('GetBitmap', None, None),
[...]
# This table maps WX classes to a list of XML tags, as listed
# in tn0014.txt:
attributes_by_class = {
'Common attributes': ('exstyle', 'bg','fg', 'enabled', 'focused',
'hidden', 'tooltip', 'font', 'help'),
'wxBitmap': None,
'wxIcon': None,
'wxButton': ('pos', 'size', 'style', 'label', 'default'),
'wxCalendarCtrl': ('pos', 'size', 'style'),
[...]
def generate_documentation():
'''
Re-creates the tables from tn0014.txt, only incorporating
any errata discovered while making wx2xrc work correctly.
'''
[...]