X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64bce500c085d5450dff58082fff150a181c1bec..6cb85701e29d4326adaf2f6273561b4ec66e250a:/wxPython/wx/tools/XRCed/xxx.py diff --git a/wxPython/wx/tools/XRCed/xxx.py b/wxPython/wx/tools/XRCed/xxx.py index bd0c72a08d..4af295088d 100644 --- a/wxPython/wx/tools/XRCed/xxx.py +++ b/wxPython/wx/tools/XRCed/xxx.py @@ -47,12 +47,16 @@ class xxxParam(xxxNode): 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): try: # handle exception if encoding is wrong self.textNode.data = unicode(value, g.currentEncoding) except UnicodeDecodeError: - wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate") + self.textNode.data = unicode(value) + #wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate") # Integer parameter class xxxParamInt(xxxParam): @@ -237,11 +241,10 @@ class xxxObject: self.params[tag] = xxxParamBitmap(node) else: # simple parameter self.params[tag] = xxxParam(node) - else: - pass - # Remove all other nodes -# element.removeChild(node) -# node.unlink() + 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: @@ -291,12 +294,18 @@ class xxxObject: 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) @@ -393,19 +402,21 @@ class xxxFrame(xxxContainer): 'tooltip'] class xxxTool(xxxObject): - allParams = ['bitmap', 'bitmap2', 'toggle', 'tooltip', 'longhelp', 'label'] + 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', 'wxTB_TEXT'] + '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'] @@ -474,7 +485,7 @@ class xxxSlider(xxxObject): 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'] @@ -618,6 +629,7 @@ class xxxSizer(xxxContainer): hasName = hasStyle = False paramDict = {'orient': ParamOrient} isSizer = True + itemTag = 'sizeritem' # different for some sizers class xxxBoxSizer(xxxSizer): allParams = ['orient'] @@ -639,6 +651,7 @@ class xxxGridSizer(xxxSizer): class xxxStdDialogButtonSizer(xxxSizer): allParams = [] + itemTag = 'button' # For repeated parameters class xxxParamMulti: @@ -737,6 +750,16 @@ class xxxSizerItem(xxxChildContainer): 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} @@ -837,7 +860,7 @@ xxxDict = { 'wxFlexGridSizer': xxxFlexGridSizer, 'wxGridBagSizer': xxxGridBagSizer, 'wxStdDialogButtonSizer': xxxStdDialogButtonSizer, - 'sizeritem': xxxSizerItem, + 'sizeritem': xxxSizerItem, 'button': xxxSizerItemButton, 'spacer': xxxSpacer, 'wxMenuBar': xxxMenuBar, @@ -902,7 +925,7 @@ def MakeEmptyXXX(parent, className): # 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):