self.textNode.data = value
else:
def value(self):
- return self.textNode.data.encode(g.currentEncoding)
+ try:
+ return self.textNode.data.encode(g.currentEncoding)
+ except LookupError:
+ return self.textNode.data.encode()
def update(self, value):
- self.textNode.data = unicode(value, g.currentEncoding)
+ try: # handle exception if encoding is wrong
+ self.textNode.data = unicode(value, g.currentEncoding)
+ except UnicodeDecodeError:
+ self.textNode.data = unicode(value)
+ #wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate")
# Integer parameter
class xxxParamInt(xxxParam):
self.params[tag] = xxxParamBitmap(node)
else: # simple parameter
self.params[tag] = xxxParam(node)
- else:
- # Remove all other nodes
+ elif node.nodeType == minidom.Node.TEXT_NODE and node.data.isspace():
+ # Remove empty text nodes
element.removeChild(node)
node.unlink()
+
# Check that all required params are set
for param in self.required:
if not self.params.has_key(param):
def panelName(self):
if self.subclass: return self.subclass + '(' + self.className + ')'
else: return self.className
+ # Sets name of tree object
+ def setTreeName(self, name):
+ if self.hasChild: obj = self.child
+ else: obj = self
+ obj.name = name
+ obj.element.setAttribute('name', name)
################################################################################
# This is a little special: it is both xxxObject and xxxNode
class xxxParamFont(xxxObject, xxxNode):
- allParams = ['size', 'style', 'weight', 'family', 'underlined',
+ allParams = ['size', 'family', 'style', 'weight', 'underlined',
'face', 'encoding']
def __init__(self, parent, element):
xxxObject.__init__(self, parent, element)
class xxxContainer(xxxObject):
hasChildren = True
+ exStyles = []
# Simulate normal parameter for encoding
class xxxEncoding:
- def __init__(self, val):
- self.encd = val
def value(self):
- return self.encd
+ return g.currentEncoding
def update(self, val):
- self.encd = val
+ g.currentEncoding = val
# Special class for root node
class xxxMainNode(xxxContainer):
# Reset required parameters after processing XML, because encoding is
# a little special
self.required = ['encoding']
- self.params['encoding'] = xxxEncoding(dom.encoding)
+ self.params['encoding'] = xxxEncoding()
################################################################################
# Top-level windwows
allParams = ['pos', 'size', 'style']
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
'tooltip']
- winStyles = ['wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN']
- exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY']
class xxxDialog(xxxContainer):
allParams = ['title', 'centered', 'pos', 'size', 'style']
paramDict = {'centered': ParamBool}
required = ['title']
default = {'title': ''}
- winStyles = ['wxDEFAULT_DIALOG_STYLE', 'wxSTAY_ON_TOP',
- 'wxDIALOG_MODAL', 'wxDIALOG_MODELESS',
- 'wxCAPTION', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', 'wxRESIZE_BOX',
+ winStyles = ['wxDEFAULT_DIALOG_STYLE',
+ 'wxCAPTION', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX', 'wxCLOSE_BOX',
+ 'wxSTAY_ON_TOP',
'wxTHICK_FRAME',
- 'wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN']
+ 'wxNO_3D', 'wxDIALOG_NO_PARENT']
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
'tooltip']
- exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY']
class xxxFrame(xxxContainer):
allParams = ['title', 'centered', 'pos', 'size', 'style']
paramDict = {'centered': ParamBool}
required = ['title']
default = {'title': ''}
- winStyles = ['wxDEFAULT_FRAME_STYLE', 'wxDEFAULT_DIALOG_STYLE',
+ winStyles = ['wxDEFAULT_FRAME_STYLE',
+ 'wxCAPTION', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX', 'wxCLOSE_BOX',
'wxSTAY_ON_TOP',
- 'wxCAPTION', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER',
- 'wxRESIZE_BOX', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX',
- 'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_TOOL_WINDOW',
- 'wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN']
+ 'wxSYSTEM_MENU', 'wxRESIZE_BORDER',
+ 'wxFRAME_TOOL_WINDOW', 'wxFRAME_NO_TASKBAR',
+ 'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_SHAPED'
+ ]
styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
'tooltip']
- exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY']
class xxxTool(xxxObject):
- allParams = ['bitmap', 'bitmap2', 'toggle', 'tooltip', 'longhelp']
+ allParams = ['bitmap', 'bitmap2', 'radio', 'toggle', 'tooltip', 'longhelp', 'label']
required = ['bitmap']
- paramDict = {'bitmap2': ParamBitmap, 'toggle': ParamBool}
+ paramDict = {'bitmap2': ParamBitmap, 'radio': ParamBool, 'toggle': ParamBool}
hasStyle = False
class xxxToolBar(xxxContainer):
- allParams = ['bitmapsize', 'margins', 'packing', 'separation',
+ allParams = ['bitmapsize', 'margins', 'packing', 'separation', 'dontattachtoframe',
'pos', 'size', 'style']
hasStyle = False
paramDict = {'bitmapsize': ParamPosSize, 'margins': ParamPosSize,
'packing': ParamInt, 'separation': ParamInt,
- 'style': ParamNonGenericStyle}
- winStyles = ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL']
+ 'dontattachtoframe': ParamBool, 'style': ParamNonGenericStyle}
+ winStyles = ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL',
+ 'wxTB_3DBUTTONS','wxTB_TEXT', 'wxTB_NOICONS', 'wxTB_NODIVIDER',
+ 'wxTB_NOALIGN', 'wxTB_HORZ_LAYOUT', 'wxTB_HORZ_TEXT']
+
+class xxxWizard(xxxContainer):
+ allParams = ['title', 'bitmap', 'pos']
+ required = ['title']
+ default = {'title': ''}
+ winStyles = []
+ exStyles = ['wxWIZARD_EX_HELPBUTTON']
+
+class xxxWizardPage(xxxContainer):
+ allParams = ['bitmap']
+ winStyles = []
+ exStyles = []
+
+class xxxWizardPageSimple(xxxContainer):
+ allParams = ['bitmap']
+ winStyles = []
+ exStyles = []
################################################################################
# Bitmap, Icon
# Just like bitmap
class xxxIcon(xxxObject):
- allParams = ['icon']
- required = ['icon']
+ allParams = []
################################################################################
# Controls
required = ['value', 'min', 'max']
winStyles = ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS',
'wxSL_LEFT', 'wxSL_RIGHT', 'wxSL_TOP', 'wxSL_BOTTOM',
- 'wxSL_BOTH', 'wxSL_SELRANGE']
+ 'wxSL_BOTH', 'wxSL_SELRANGE', 'wxSL_INVERSE']
class xxxGauge(xxxObject):
allParams = ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel']
paramDict = {'usenotebooksizer': ParamBool}
winStyles = ['wxNB_FIXEDWIDTH', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM']
+class xxxSplitterWindow(xxxContainer):
+ allParams = ['orientation', 'sashpos', 'minsize', 'pos', 'size', 'style']
+ paramDict = {'orientation': ParamOrientation, 'sashpos': ParamUnit, 'minsize': ParamUnit }
+ winStyles = ['wxSP_3D', 'wxSP_3DSASH', 'wxSP_3DBORDER', 'wxSP_BORDER',
+ 'wxSP_NOBORDER', 'wxSP_PERMIT_UNSPLIT', 'wxSP_LIVE_UPDATE',
+ 'wxSP_NO_XP_THEME' ]
+
class xxxGenericDirCtrl(xxxObject):
allParams = ['defaultfolder', 'filter', 'defaultfilter', 'pos', 'size', 'style']
paramDict = {'defaultfilter': ParamInt}
paramDict = {'value': ParamInt}
winStyles = ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP']
+class xxxToggleButton(xxxObject):
+ allParams = ['label', 'checked', 'pos', 'size', 'style']
+ paramDict = {'checked': ParamBool}
+ required = ['label']
+
################################################################################
# Boxes
class xxxCheckBox(xxxObject):
allParams = ['label', 'checked', 'pos', 'size', 'style']
paramDict = {'checked': ParamBool}
+ winStyles = ['wxCHK_2STATE', 'wxCHK_3STATE', 'wxCHK_ALLOW_3RD_STATE_FOR_USER',
+ 'wxALIGN_RIGHT']
required = ['label']
class xxxComboBox(xxxObject):
hasName = hasStyle = False
paramDict = {'orient': ParamOrient}
isSizer = True
+ itemTag = 'sizeritem' # different for some sizers
class xxxBoxSizer(xxxSizer):
allParams = ['orient']
required = ['cols']
default = {'cols': '2', 'rows': '2'}
+class xxxStdDialogButtonSizer(xxxSizer):
+ allParams = []
+ itemTag = 'button'
+
# For repeated parameters
class xxxParamMulti:
def __init__(self, node):
self.child.allParams = self.child.allParams[:]
self.child.allParams.remove('pos')
+class xxxSizerItemButton(xxxSizerItem):
+ allParams = []
+ paramDict = {}
+ def __init__(self, parent, element):
+ xxxChildContainer.__init__(self, parent, element)
+ # Remove pos parameter - not needed for sizeritems
+ if 'pos' in self.child.allParams:
+ self.child.allParams = self.child.allParams[:]
+ self.child.allParams.remove('pos')
+
class xxxNotebookPage(xxxChildContainer):
allParams = ['label', 'selected']
paramDict = {'selected': ParamBool}
'wxFrame': xxxFrame,
'tool': xxxTool,
'wxToolBar': xxxToolBar,
+ 'wxWizard': xxxWizard,
+ 'wxWizardPage': xxxWizardPage,
+ 'wxWizardPageSimple': xxxWizardPageSimple,
'wxBitmap': xxxBitmap,
'wxIcon': xxxIcon,
'wxBitmapButton': xxxBitmapButton,
'wxRadioButton': xxxRadioButton,
'wxSpinButton': xxxSpinButton,
+ 'wxToggleButton' : xxxToggleButton,
'wxStaticBox': xxxStaticBox,
'wxStaticBitmap': xxxStaticBitmap,
'wxListCtrl': xxxListCtrl,
'wxCheckListBox': xxxCheckList,
'wxNotebook': xxxNotebook,
+ 'wxSplitterWindow': xxxSplitterWindow,
'notebookpage': xxxNotebookPage,
'wxHtmlWindow': xxxHtmlWindow,
'wxCalendarCtrl': xxxCalendarCtrl,
'wxGridSizer': xxxGridSizer,
'wxFlexGridSizer': xxxFlexGridSizer,
'wxGridBagSizer': xxxGridBagSizer,
- 'sizeritem': xxxSizerItem,
+ 'wxStdDialogButtonSizer': xxxStdDialogButtonSizer,
+ 'sizeritem': xxxSizerItem, 'button': xxxSizerItemButton,
'spacer': xxxSpacer,
'wxMenuBar': xxxMenuBar,
# If parent is a sizer, we should create sizeritem object, except for spacers
if parent:
if parent.isSizer and className != 'spacer':
- sizerItemElem = MakeEmptyDOM('sizeritem')
+ sizerItemElem = MakeEmptyDOM(parent.itemTag)
sizerItemElem.appendChild(elem)
elem = sizerItemElem
elif isinstance(parent, xxxNotebook):