1 # Name: xxx.py ('xxx' is easy to distinguish from 'wx' :) )
2 # Purpose: XML interface classes
3 # Author: Roman Rolinsky <rolinsky@mema.ucl.ac.be>
7 from xml
.dom
import minidom
10 import traceback
, types
12 # Base class for interface parameter classes
14 def __init__(self
, node
):
17 self
.node
.parentNode
.removeChild(self
.node
)
20 # Generic (text) parameter class
21 class xxxParam(xxxNode
):
22 # Standard use: for text nodes
23 def __init__(self
, node
):
24 xxxNode
.__init
__(self
, node
)
25 if not node
.hasChildNodes():
26 # If does not have child nodes, create empty text node
27 text
= g
.tree
.dom
.createTextNode('')
28 node
.appendChild(text
)
30 text
= node
.childNodes
[0] # first child must be text node
31 assert text
.nodeType
== minidom
.Node
.TEXT_NODE
32 # Append other text nodes if present and delete them
34 for n
in node
.childNodes
[1:]:
35 if n
.nodeType
== minidom
.Node
.TEXT_NODE
:
40 if extraText
: text
.data
= text
.data
+ extraText
41 # Use convertion from unicode to current encoding
43 # Value returns string
44 if wx
.USE_UNICODE
: # no conversion is needed
46 return self
.textNode
.data
47 def update(self
, value
):
48 self
.textNode
.data
= value
52 return self
.textNode
.data
.encode(g
.currentEncoding
)
54 return self
.textNode
.data
.encode()
55 def update(self
, value
):
56 try: # handle exception if encoding is wrong
57 self
.textNode
.data
= unicode(value
, g
.currentEncoding
)
58 except UnicodeDecodeError:
59 self
.textNode
.data
= unicode(value
)
60 #wx.LogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate")
63 class xxxParamInt(xxxParam
):
64 # Standard use: for text nodes
65 def __init__(self
, node
):
66 xxxParam
.__init
__(self
, node
)
67 # Value returns string
70 return int(self
.textNode
.data
)
72 return -1 # invalid value
73 def update(self
, value
):
74 self
.textNode
.data
= str(value
)
77 class xxxParamContent(xxxNode
):
78 def __init__(self
, node
):
79 xxxNode
.__init
__(self
, node
)
80 data
, l
= [], [] # data is needed to quicker value retrieval
81 nodes
= node
.childNodes
[:] # make a copy of the child list
83 if n
.nodeType
== minidom
.Node
.ELEMENT_NODE
:
84 assert n
.tagName
== 'item', 'bad content content'
85 if not n
.hasChildNodes():
86 # If does not have child nodes, create empty text node
87 text
= g
.tree
.dom
.createTextNode('')
88 node
.appendChild(text
)
91 text
= n
.childNodes
[0] # first child must be text node
92 assert text
.nodeType
== minidom
.Node
.TEXT_NODE
94 data
.append(text
.data
)
98 self
.l
, self
.data
= l
, data
101 def update(self
, value
):
102 # If number if items is not the same, recreate children
103 if len(value
) != len(self
.l
): # remove first if number of items has changed
104 childNodes
= self
.node
.childNodes
[:]
106 self
.node
.removeChild(n
)
109 itemElem
= g
.tree
.dom
.createElement('item')
110 itemText
= g
.tree
.dom
.createTextNode(str)
111 itemElem
.appendChild(itemText
)
112 self
.node
.appendChild(itemElem
)
116 for i
in range(len(value
)):
117 self
.l
[i
].data
= value
[i
]
120 # Content parameter for checklist
121 class xxxParamContentCheckList(xxxNode
):
122 def __init__(self
, node
):
123 xxxNode
.__init
__(self
, node
)
124 data
, l
= [], [] # data is needed to quicker value retrieval
125 nodes
= node
.childNodes
[:] # make a copy of the child list
127 if n
.nodeType
== minidom
.Node
.ELEMENT_NODE
:
128 assert n
.tagName
== 'item', 'bad content content'
129 checked
= n
.getAttribute('checked')
130 if not checked
: checked
= 0
131 if not n
.hasChildNodes():
132 # If does not have child nodes, create empty text node
133 text
= g
.tree
.dom
.createTextNode('')
134 node
.appendChild(text
)
137 text
= n
.childNodes
[0] # first child must be text node
138 assert text
.nodeType
== minidom
.Node
.TEXT_NODE
140 data
.append((str(text
.data
), int(checked
)))
144 self
.l
, self
.data
= l
, data
147 def update(self
, value
):
148 # If number if items is not the same, recreate children
149 if len(value
) != len(self
.l
): # remove first if number of items has changed
150 childNodes
= self
.node
.childNodes
[:]
152 self
.node
.removeChild(n
)
155 itemElem
= g
.tree
.dom
.createElement('item')
156 # Add checked only if True
157 if ch
: itemElem
.setAttribute('checked', '1')
158 itemText
= g
.tree
.dom
.createTextNode(s
)
159 itemElem
.appendChild(itemText
)
160 self
.node
.appendChild(itemElem
)
161 l
.append((itemText
, itemElem
))
164 for i
in range(len(value
)):
165 self
.l
[i
][0].data
= value
[i
][0]
166 self
.l
[i
][1].setAttribute('checked', str(value
[i
][1]))
170 class xxxParamBitmap(xxxParam
):
171 def __init__(self
, node
):
172 xxxParam
.__init
__(self
, node
)
173 self
.stock_id
= node
.getAttribute('stock_id')
175 return [self
.stock_id
, xxxParam
.value(self
)]
176 def update(self
, value
):
177 self
.stock_id
= value
[0]
179 self
.node
.setAttribute('stock_id', self
.stock_id
)
180 elif self
.node
.hasAttribute('stock_id'):
181 self
.node
.removeAttribute('stock_id')
182 xxxParam
.update(self
, value
[1])
184 ################################################################################
186 # Classes to interface DOM objects
189 hasChildren
= False # has children elements?
190 hasStyle
= True # almost everyone
191 hasName
= True # has name attribute?
192 isSizer
= hasChild
= False
194 allParams
= None # Some nodes have no parameters
195 # Style parameters (all optional)
196 styles
= ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'tooltip']
200 bitmapTags
= ['bitmap', 'bitmap2', 'icon']
201 # Required paremeters: none by default
203 # Default parameters with default values
207 # Window styles and extended styles
211 # Construct a new xxx object from DOM element
212 # parent is parent xxx object (or None if none), element is DOM element object
213 def __init__(self
, parent
, element
, refElem
=None):
216 self
.refElem
= refElem
218 # Reference are dereferenced
219 if element
.tagName
== 'object_ref':
220 # Find original object
221 self
.ref
= element
.getAttribute('ref')
223 self
.className
= self
.refElem
.getAttribute('class')
225 self
.className
= 'xxxUnknown'
230 self
.className
= element
.getAttribute('class')
231 self
.subclass
= element
.getAttribute('subclass')
232 if self
.hasName
: self
.name
= element
.getAttribute('name')
233 # Set parameters (text element children)
235 for n
in element
.childNodes
[:]:
236 if n
.nodeType
== minidom
.Node
.ELEMENT_NODE
:
238 if tag
in ['object', 'object_ref']:
239 continue # do nothing for object children here
240 elif tag
not in self
.allParams
and tag
not in self
.styles
:
241 print 'WARNING: unknown parameter for %s: %s' % \
242 (self
.className
, tag
)
243 elif tag
in self
.specials
:
245 elif tag
== 'content':
246 if self
.className
== 'wxCheckListBox':
247 self
.params
[tag
] = xxxParamContentCheckList(n
)
249 self
.params
[tag
] = xxxParamContent(n
)
250 elif tag
== 'font': # has children
251 self
.params
[tag
] = xxxParamFont(element
, n
)
252 elif tag
in self
.bitmapTags
:
253 # Can have attributes
254 self
.params
[tag
] = xxxParamBitmap(n
)
255 else: # simple parameter
256 self
.params
[tag
] = xxxParam(n
)
257 elif n
.nodeType
== minidom
.Node
.TEXT_NODE
and n
.data
.isspace():
258 # Remove empty text nodes
259 element
.removeChild(n
)
262 # Check that all required params are set
263 for param
in self
.required
:
264 if not self
.params
.has_key(param
):
265 # If default is specified, set it
266 if self
.default
.has_key(param
):
267 elem
= g
.tree
.dom
.createElement(param
)
268 if param
== 'content':
269 if self
.className
== 'wxCheckListBox':
270 self
.params
[param
] = xxxParamContentCheckList(elem
)
272 self
.params
[param
] = xxxParamContent(elem
)
274 self
.params
[param
] = xxxParam(elem
)
275 # Find place to put new element: first present element after param
277 paramStyles
= self
.allParams
+ self
.styles
278 for p
in paramStyles
[paramStyles
.index(param
) + 1:]:
279 # Content params don't have same type
280 if self
.params
.has_key(p
) and p
!= 'content':
284 nextTextElem
= self
.params
[p
].node
285 self
.node
.insertBefore(elem
, nextTextElem
)
287 self
.node
.appendChild(elem
)
289 wx
.LogWarning('Required parameter %s of %s missing' %
290 (param
, self
.className
))
291 # Returns real tree object
292 def treeObject(self
):
293 if self
.hasChild
: return self
.child
295 # Returns tree image index
297 if self
.hasChild
: return self
.child
.treeImage()
299 # Class name plus wx name
301 if self
.hasChild
: return self
.child
.treeName()
302 if self
.subclass
: className
= self
.subclass
303 else: className
= self
.className
304 if self
.hasName
and self
.name
: return className
+ ' "' + self
.name
+ '"'
306 # Class name or subclass
308 if self
.subclass
: name
= self
.subclass
+ '(' + self
.className
+ ')'
309 name
= self
.className
310 if self
.ref
: name
= 'ref: ' + self
.ref
+ ', ' + name
312 # Sets name of tree object
313 def setTreeName(self
, name
):
314 if self
.hasChild
: obj
= self
.child
317 obj
.node
.setAttribute('name', name
)
318 # Set normal (text) params
319 def set(self
, param
, value
):
321 self
.params
[param
].update(value
)
323 p
= xxxParam(g
.tree
.dom
.createElement(param
))
325 self
.params
[param
] = p
326 # Special processing for growablecols-like parameters
327 # represented by several nodes
328 def special(self
, tag
, node
):
329 if not self
.params
.has_key(tag
):
330 # Create new multi-group
331 self
.params
[tag
] = xxxParamMulti(node
)
332 self
.params
[tag
].append(xxxParamInt(node
))
333 def setSpecial(self
, param
, value
):
334 # Straightforward implementation: remove, add again
335 self
.params
[param
].remove()
336 del self
.params
[param
]
338 node
= g
.tree
.dom
.createElement(param
)
339 text
= g
.tree
.dom
.createTextNode(str(i
))
340 node
.appendChild(text
)
341 self
.node
.appendChild(node
)
342 self
.special(param
, node
)
344 # Imitation of FindResource/DoFindResource from xmlres.cpp
345 def DoFindResource(parent
, name
, classname
, recursive
):
346 for n
in parent
.childNodes
:
347 if n
.nodeType
== minidom
.Node
.ELEMENT_NODE
and \
348 n
.tagName
in ['object', 'object_ref'] and \
349 n
.getAttribute('name') == name
:
350 cls
= n
.getAttribute('class')
351 if not classname
or cls
== classname
: return n
352 if not cls
or n
.tagName
== 'object_ref':
353 refName
= n
.getAttribute('ref')
354 if not refName
: continue
355 refNode
= FindResource(refName
)
356 if refName
and refNode
.getAttribute('class') == classname
:
359 for n
in parent
.childNodes
:
360 if n
.nodeType
== minidom
.Node
.ELEMENT_NODE
and \
361 n
.tagName
in ['object', 'object_ref']:
362 found
= DoFindResource(n
, name
, classname
, True)
363 if found
: return found
364 def FindResource(name
, classname
='', recursive
=True):
365 found
= DoFindResource(g
.tree
.mainNode
, name
, classname
, recursive
)
366 if found
: return found
367 wx
.LogError('XRC resource "%s" not found!' % name
)
370 ################################################################################
372 # This is a little special: it is both xxxObject and xxxNode
373 class xxxParamFont(xxxObject
, xxxNode
):
374 allParams
= ['size', 'family', 'style', 'weight', 'underlined',
376 def __init__(self
, parent
, element
):
377 xxxObject
.__init
__(self
, parent
, element
)
378 xxxNode
.__init
__(self
, element
)
379 self
.parentNode
= parent
# required to behave similar to DOM node
381 for p
in self
.allParams
:
383 v
.append(str(self
.params
[p
].value()))
387 def update(self
, value
):
388 # `value' is a list of strings corresponding to all parameters
390 # Remove old elements first
391 childNodes
= elem
.childNodes
[:]
392 for node
in childNodes
: elem
.removeChild(node
)
396 for param
in self
.allParams
:
398 fontElem
= g
.tree
.dom
.createElement(param
)
399 textNode
= g
.tree
.dom
.createTextNode(value
[i
])
400 self
.params
[param
] = textNode
401 fontElem
.appendChild(textNode
)
402 elem
.appendChild(fontElem
)
409 ################################################################################
411 class xxxContainer(xxxObject
):
415 # Simulate normal parameter for encoding
418 return g
.currentEncoding
419 def update(self
, val
):
420 g
.currentEncoding
= val
422 # Special class for root node
423 class xxxMainNode(xxxContainer
):
424 allParams
= ['encoding']
425 hasStyle
= hasName
= False
426 def __init__(self
, dom
):
427 xxxContainer
.__init
__(self
, None, dom
.documentElement
)
428 self
.className
= 'XML tree'
429 # Reset required parameters after processing XML, because encoding is
431 self
.required
= ['encoding']
432 self
.params
['encoding'] = xxxEncoding()
434 ################################################################################
437 class xxxPanel(xxxContainer
):
438 allParams
= ['pos', 'size', 'style']
439 winStyles
= ['wxNO_3D', 'wxTAB_TRAVERSAL']
440 styles
= ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
443 class xxxDialog(xxxContainer
):
444 allParams
= ['title', 'centered', 'pos', 'size', 'style']
445 paramDict
= {'centered': ParamBool}
447 default
= {'title': ''}
448 winStyles
= ['wxDEFAULT_DIALOG_STYLE', 'wxCAPTION',
449 'wxSTAY_ON_TOP', 'wxSYSTEM_MENU', 'wxTHICK_FRAME',
450 'wxRESIZE_BORDER', 'wxRESIZE_BOX', 'wxCLOSE_BOX',
451 'wxMAXIMIZE_BOX', 'wxMINIMIZE_BOX',
452 'wxDIALOG_MODAL', 'wxDIALOG_MODELESS', 'wxDIALOG_NO_PARENT'
453 'wxNO_3D', 'wxTAB_TRAVERSAL']
454 exStyles
= ['wxWS_EX_VALIDATE_RECURSIVELY', 'wxDIALOG_EX_METAL']
455 styles
= ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
458 class xxxFrame(xxxContainer
):
459 allParams
= ['title', 'centered', 'pos', 'size', 'style']
460 paramDict
= {'centered': ParamBool}
462 default
= {'title': ''}
463 winStyles
= ['wxDEFAULT_FRAME_STYLE', 'wxDEFAULT_DIALOG_STYLE', 'wxCAPTION',
464 'wxSTAY_ON_TOP', 'wxSYSTEM_MENU', 'wxTHICK_FRAME',
465 'wxRESIZE_BORDER', 'wxRESIZE_BOX', 'wxCLOSE_BOX',
466 'wxMAXIMIZE_BOX', 'wxMINIMIZE_BOX',
467 'wxFRAME_NO_TASKBAR', 'wxFRAME_SHAPED', 'wxFRAME_TOOL_WINDOW',
468 'wxFRAME_FLOAT_ON_PARENT',
469 'wxNO_3D', 'wxTAB_TRAVERSAL']
470 exStyles
= ['wxWS_EX_VALIDATE_RECURSIVELY', 'wxFRAME_EX_METAL']
471 styles
= ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle',
474 class xxxTool(xxxObject
):
475 allParams
= ['bitmap', 'bitmap2', 'radio', 'toggle', 'tooltip', 'longhelp', 'label']
476 required
= ['bitmap']
477 paramDict
= {'bitmap2': ParamBitmap, 'radio': ParamBool, 'toggle': ParamBool}
480 class xxxToolBar(xxxContainer
):
481 allParams
= ['bitmapsize', 'margins', 'packing', 'separation', 'dontattachtoframe',
482 'pos', 'size', 'style']
484 paramDict
= {'bitmapsize': ParamPosSize
, 'margins': ParamPosSize
,
485 'packing': ParamUnit
, 'separation': ParamUnit
,
486 'dontattachtoframe': ParamBool
, 'style': ParamNonGenericStyle
}
487 winStyles
= ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL',
488 'wxTB_3DBUTTONS','wxTB_TEXT', 'wxTB_NOICONS', 'wxTB_NODIVIDER',
489 'wxTB_NOALIGN', 'wxTB_HORZ_LAYOUT', 'wxTB_HORZ_TEXT']
491 class xxxStatusBar(xxxObject
):
493 allParams
= ['fields', 'widths', 'styles', 'style']
494 paramDict
= {'fields': ParamIntNN
, 'widths': ParamText
, 'styles': ParamText
,
495 'style': ParamNonGenericStyle
}
496 winStyles
= ['wxST_SIZEGRIP']
498 class xxxWizard(xxxContainer
):
499 allParams
= ['title', 'bitmap', 'pos']
501 default
= {'title': ''}
503 exStyles
= ['wxWIZARD_EX_HELPBUTTON']
504 styles
= ['fg', 'bg', 'font', 'exstyle']
506 class xxxWizardPage(xxxContainer
):
507 allParams
= ['bitmap']
511 class xxxWizardPageSimple(xxxContainer
):
512 allParams
= ['bitmap']
516 ################################################################################
519 class xxxBitmap(xxxObject
):
520 allParams
= ['bitmap']
521 required
= ['bitmap']
524 class xxxIcon(xxxObject
):
527 ################################################################################
530 class xxxStaticText(xxxObject
):
531 allParams
= ['label', 'pos', 'size', 'style']
533 default
= {'label': ''}
534 winStyles
= ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE']
536 class xxxStaticLine(xxxObject
):
537 allParams
= ['pos', 'size', 'style']
538 winStyles
= ['wxLI_HORIZONTAL', 'wxLI_VERTICAL']
540 class xxxStaticBitmap(xxxObject
):
541 allParams
= ['bitmap', 'pos', 'size', 'style']
542 required
= ['bitmap']
544 class xxxTextCtrl(xxxObject
):
545 allParams
= ['value', 'pos', 'size', 'style']
546 winStyles
= ['wxTE_NO_VSCROLL',
548 'wxTE_PROCESS_ENTER',
564 paramDict
= {'value': ParamMultilineText}
566 class xxxChoice(xxxObject
):
567 allParams
= ['content', 'selection', 'pos', 'size', 'style']
568 required
= ['content']
569 default
= {'content': '[]'}
570 winStyles
= ['wxCB_SORT']
572 class xxxSlider(xxxObject
):
573 allParams
= ['value', 'min', 'max', 'pos', 'size', 'style',
574 'tickfreq', 'pagesize', 'linesize', 'thumb', 'tick',
576 paramDict
= {'value': ParamInt
, 'tickfreq': ParamIntNN
, 'pagesize': ParamIntNN
,
577 'linesize': ParamIntNN
, 'thumb': ParamUnit
,
578 'tick': ParamInt
, 'selmin': ParamInt
, 'selmax': ParamInt
}
579 required
= ['value', 'min', 'max']
580 winStyles
= ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS',
581 'wxSL_LEFT', 'wxSL_RIGHT', 'wxSL_TOP', 'wxSL_BOTTOM',
582 'wxSL_BOTH', 'wxSL_SELRANGE', 'wxSL_INVERSE']
584 class xxxGauge(xxxObject
):
585 allParams
= ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel']
586 paramDict
= {'range': ParamIntNN
, 'value': ParamIntNN
,
587 'shadow': ParamIntNN
, 'bezel': ParamIntNN
}
588 winStyles
= ['wxGA_HORIZONTAL', 'wxGA_VERTICAL', 'wxGA_PROGRESSBAR', 'wxGA_SMOOTH']
590 class xxxScrollBar(xxxObject
):
591 allParams
= ['pos', 'size', 'style', 'value', 'thumbsize', 'range', 'pagesize']
592 paramDict
= {'value': ParamIntNN
, 'range': ParamIntNN
, 'thumbsize': ParamIntNN
,
593 'pagesize': ParamIntNN
}
594 winStyles
= ['wxSB_HORIZONTAL', 'wxSB_VERTICAL']
596 class xxxListCtrl(xxxObject
):
597 allParams
= ['pos', 'size', 'style']
598 winStyles
= ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON',
599 'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE',
600 'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER',
601 'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING',
602 'wxLC_VIRTUAL', 'wxLC_HRULES', 'wxLC_VRULES', 'wxLC_NO_SORT_HEADER']
604 class xxxTreeCtrl(xxxObject
):
605 allParams
= ['pos', 'size', 'style']
606 winStyles
= ['wxTR_EDIT_LABELS',
609 'wxTR_TWIST_BUTTONS',
611 'wxTR_FULL_ROW_HIGHLIGHT',
612 'wxTR_LINES_AT_ROOT',
615 'wxTR_HAS_VARIABLE_ROW_HEIGHT',
619 'wxTR_DEFAULT_STYLE']
621 class xxxHtmlWindow(xxxObject
):
622 allParams
= ['pos', 'size', 'style', 'borders', 'url', 'htmlcode']
623 paramDict
= {'htmlcode':ParamMultilineText}
624 winStyles
= ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO', 'wxHW_NO_SELECTION']
626 class xxxCalendarCtrl(xxxObject
):
627 allParams
= ['pos', 'size', 'style']
628 winStyles
= ['wxCAL_SUNDAY_FIRST', 'wxCAL_MONDAY_FIRST', 'wxCAL_SHOW_HOLIDAYS',
629 'wxCAL_NO_YEAR_CHANGE', 'wxCAL_NO_MONTH_CHANGE',
630 'wxCAL_SEQUENTIAL_MONTH_SELECTION', 'wxCAL_SHOW_SURROUNDING_WEEKS']
632 class xxxNotebook(xxxContainer
):
633 allParams
= ['pos', 'size', 'style']
634 winStyles
= ['wxNB_TOP', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM',
635 'wxNB_FIXEDWIDTH', 'wxNB_MULTILINE', 'wxNB_NOPAGETHEME', 'wxNB_FLAT']
637 class xxxChoicebook(xxxContainer
):
638 allParams
= ['pos', 'size', 'style']
639 winStyles
= ['wxCHB_DEFAULT', 'wxCHB_LEFT', 'wxCHB_RIGHT', 'wxCHB_TOP', 'wxCHB_BOTTOM']
641 class xxxListbook(xxxContainer
):
642 allParams
= ['pos', 'size', 'style']
643 winStyles
= ['wxLB_DEFAULT', 'wxLB_LEFT', 'wxLB_RIGHT', 'wxLB_TOP', 'wxLB_BOTTOM']
645 class xxxSplitterWindow(xxxContainer
):
646 allParams
= ['orientation', 'sashpos', 'minsize', 'pos', 'size', 'style']
647 paramDict
= {'orientation': ParamOrientation, 'sashpos': ParamUnit, 'minsize': ParamUnit }
648 winStyles
= ['wxSP_3D', 'wxSP_3DSASH', 'wxSP_3DBORDER',
649 'wxSP_FULLSASH', 'wxSP_NOBORDER', 'wxSP_PERMIT_UNSPLIT', 'wxSP_LIVE_UPDATE',
652 class xxxGenericDirCtrl(xxxObject
):
653 allParams
= ['defaultfolder', 'filter', 'defaultfilter', 'pos', 'size', 'style']
654 paramDict
= {'defaultfilter': ParamIntNN}
655 winStyles
= ['wxDIRCTRL_DIR_ONLY', 'wxDIRCTRL_3D_INTERNAL', 'wxDIRCTRL_SELECT_FIRST',
656 'wxDIRCTRL_SHOW_FILTERS']
658 class xxxScrolledWindow(xxxContainer
):
659 allParams
= ['pos', 'size', 'style']
660 winStyles
= ['wxHSCROLL', 'wxVSCROLL', 'wxNO_3D', 'wxTAB_TRAVERSAL']
662 class xxxDateCtrl(xxxObject
):
663 allParams
= ['pos', 'size', 'style', 'borders']
664 winStyles
= ['wxDP_DEFAULT', 'wxDP_SPIN', 'wxDP_DROPDOWN',
665 'wxDP_ALLOWNONE', 'wxDP_SHOWCENTURY']
667 class xxxGrid(xxxObject
):
668 allParams
= ['pos', 'size', 'style']
670 class xxxFilePickerCtrl(xxxObject
):
671 allParams
= ['value', 'message', 'wildcard', 'pos', 'size', 'style']
672 winStyles
= ['wxFLP_OPEN', 'wxFLP_SAVE', 'wxFLP_OVERWRITE_PROMPT',
673 'wxFLP_FILE_MUST_EXIST', 'wxFLP_CHANGE_DIR',
674 'wxFLP_DEFAULT_STYLE']
677 ################################################################################
680 class xxxButton(xxxObject
):
681 allParams
= ['label', 'default', 'pos', 'size', 'style']
682 paramDict
= {'default': ParamBool}
684 winStyles
= ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM', 'wxBU_EXACTFIT',
687 class xxxBitmapButton(xxxObject
):
688 allParams
= ['bitmap', 'selected', 'focus', 'disabled', 'default',
689 'pos', 'size', 'style']
690 paramDict
= {'selected': ParamBitmap
, 'focus': ParamBitmap
, 'disabled': ParamBitmap
,
691 'default': ParamBool
}
692 required
= ['bitmap']
693 winStyles
= ['wxBU_AUTODRAW', 'wxBU_LEFT', 'wxBU_RIGHT',
694 'wxBU_TOP', 'wxBU_BOTTOM']
696 class xxxRadioButton(xxxObject
):
697 allParams
= ['label', 'value', 'pos', 'size', 'style']
698 paramDict
= {'value': ParamBool}
700 winStyles
= ['wxRB_GROUP', 'wxRB_SINGLE']
702 class xxxSpinButton(xxxObject
):
703 allParams
= ['value', 'min', 'max', 'pos', 'size', 'style']
704 paramDict
= {'value': ParamInt}
705 winStyles
= ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP']
707 class xxxSpinCtrl(xxxObject
):
708 allParams
= ['value', 'min', 'max', 'pos', 'size', 'style']
709 paramDict
= {'value': ParamInt}
710 winStyles
= ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP']
712 class xxxToggleButton(xxxObject
):
713 allParams
= ['label', 'checked', 'pos', 'size', 'style']
714 paramDict
= {'checked': ParamBool}
717 ################################################################################
720 class xxxStaticBox(xxxObject
):
721 allParams
= ['label', 'pos', 'size', 'style']
724 class xxxRadioBox(xxxObject
):
725 allParams
= ['label', 'content', 'selection', 'dimension', 'pos', 'size', 'style']
726 paramDict
= {'dimension': ParamIntNN}
727 required
= ['label', 'content']
728 default
= {'content': '[]'}
729 winStyles
= ['wxRA_SPECIFY_ROWS', 'wxRA_SPECIFY_COLS', 'wxRA_HORIZONTAL',
732 class xxxCheckBox(xxxObject
):
733 allParams
= ['label', 'checked', 'pos', 'size', 'style']
734 paramDict
= {'checked': ParamBool}
735 winStyles
= ['wxCHK_2STATE', 'wxCHK_3STATE', 'wxCHK_ALLOW_3RD_STATE_FOR_USER',
739 class xxxComboBox(xxxObject
):
740 allParams
= ['content', 'selection', 'value', 'pos', 'size', 'style']
741 required
= ['content']
742 default
= {'content': '[]'}
743 winStyles
= ['wxCB_SIMPLE', 'wxCB_SORT', 'wxCB_READONLY', 'wxCB_DROPDOWN']
745 class xxxListBox(xxxObject
):
746 allParams
= ['content', 'selection', 'pos', 'size', 'style']
747 required
= ['content']
748 default
= {'content': '[]'}
749 winStyles
= ['wxLB_SINGLE', 'wxLB_MULTIPLE', 'wxLB_EXTENDED', 'wxLB_HSCROLL',
750 'wxLB_ALWAYS_SB', 'wxLB_NEEDED_SB', 'wxLB_SORT']
752 class xxxCheckList(xxxObject
):
753 allParams
= ['content', 'pos', 'size', 'style']
754 required
= ['content']
755 default
= {'content': '[]'}
756 winStyles
= ['wxLB_SINGLE', 'wxLB_MULTIPLE', 'wxLB_EXTENDED', 'wxLB_HSCROLL',
757 'wxLB_ALWAYS_SB', 'wxLB_NEEDED_SB', 'wxLB_SORT']
758 paramDict
= {'content': ParamContentCheckList}
760 ################################################################################
763 class xxxSizer(xxxContainer
):
764 hasName
= hasStyle
= False
765 paramDict
= {'orient': ParamOrient}
767 itemTag
= 'sizeritem' # different for some sizers
769 class xxxBoxSizer(xxxSizer
):
770 allParams
= ['orient']
771 required
= ['orient']
772 default
= {'orient': 'wxVERTICAL'}
773 # Tree icon depends on orientation
775 if self
.params
['orient'].value() == 'wxHORIZONTAL': return self
.imageH
776 else: return self
.imageV
778 class xxxStaticBoxSizer(xxxBoxSizer
):
779 allParams
= ['label', 'orient']
780 required
= ['label', 'orient']
782 class xxxGridSizer(xxxSizer
):
783 allParams
= ['cols', 'rows', 'vgap', 'hgap']
785 default
= {'cols': '2', 'rows': '2'}
787 class xxxStdDialogButtonSizer(xxxSizer
):
791 # For repeated parameters
793 def __init__(self
, node
):
795 self
.l
, self
.data
= [], []
796 def append(self
, param
):
798 self
.data
.append(param
.value())
804 self
.l
, self
.data
= [], []
806 class xxxFlexGridSizer(xxxGridSizer
):
807 specials
= ['growablecols', 'growablerows']
808 allParams
= ['cols', 'rows', 'vgap', 'hgap'] + specials
809 paramDict
= {'growablecols': ParamIntList, 'growablerows': ParamIntList}
811 class xxxGridBagSizer(xxxSizer
):
812 specials
= ['growablecols', 'growablerows']
813 allParams
= ['vgap', 'hgap'] + specials
814 paramDict
= {'growablecols': ParamIntList, 'growablerows': ParamIntList}
816 # Container with only one child.
818 class xxxChildContainer(xxxObject
):
819 hasName
= hasStyle
= False
821 def __init__(self
, parent
, element
, refElem
=None):
822 xxxObject
.__init
__(self
, parent
, element
, refElem
)
823 # Must have one child with 'object' tag, but we don't check it
824 nodes
= element
.childNodes
[:] # create copy
826 if node
.nodeType
== minidom
.Node
.ELEMENT_NODE
:
827 if node
.tagName
in ['object', 'object_ref']:
828 # Create new xxx object for child node
829 self
.child
= MakeXXXFromDOM(self
, node
)
830 self
.child
.parent
= parent
831 # Copy hasChildren and isSizer attributes
832 self
.hasChildren
= self
.child
.hasChildren
833 self
.isSizer
= self
.child
.isSizer
836 element
.removeChild(node
)
838 assert 0, 'no child found'
839 def resetChild(self
, xxx
):
840 '''Reset child info (for replacing with another class).'''
842 self
.hasChildren
= xxx
.hasChildren
843 self
.isSizer
= xxx
.isSizer
845 class xxxSizerItem(xxxChildContainer
):
846 allParams
= ['option', 'flag', 'border', 'minsize', 'ratio']
847 paramDict
= {'option': ParamInt, 'minsize': ParamPosSize, 'ratio': ParamPosSize}
849 defaults_control
= {}
850 def __init__(self
, parent
, element
, refElem
=None):
851 # For GridBag sizer items, extra parameters added
852 if isinstance(parent
, xxxGridBagSizer
):
853 self
.allParams
= self
.allParams
+ ['cellpos', 'cellspan']
854 xxxChildContainer
.__init
__(self
, parent
, element
, refElem
)
855 # Remove pos parameter - not needed for sizeritems
856 if 'pos' in self
.child
.allParams
:
857 self
.child
.allParams
= self
.child
.allParams
[:]
858 self
.child
.allParams
.remove('pos')
859 # Set defaults for some children types
860 if isinstance(self
.child
, xxxContainer
) and not self
.child
.isSizer
:
861 for param
,v
in self
.defaults_panel
.items():
864 elif isinstance(self
.child
, xxxObject
):
865 for param
,v
in self
.defaults_control
.items():
867 def resetChild(self
, xxx
):
868 xxxChildContainer
.resetChild(self
, xxx
)
869 # Remove pos parameter - not needed for sizeritems
870 if 'pos' in self
.child
.allParams
:
871 self
.child
.allParams
= self
.child
.allParams
[:]
872 self
.child
.allParams
.remove('pos')
874 class xxxSizerItemButton(xxxSizerItem
):
877 def __init__(self
, parent
, element
, refElem
=None):
878 xxxChildContainer
.__init
__(self
, parent
, element
, refElem
=None)
879 # Remove pos parameter - not needed for sizeritems
880 if 'pos' in self
.child
.allParams
:
881 self
.child
.allParams
= self
.child
.allParams
[:]
882 self
.child
.allParams
.remove('pos')
884 class xxxPage(xxxChildContainer
):
885 allParams
= ['label', 'selected']
886 paramDict
= {'selected': ParamBool}
888 def __init__(self
, parent
, element
, refElem
=None):
889 xxxChildContainer
.__init
__(self
, parent
, element
, refElem
)
890 # pos and size dont matter for notebookpages
891 if 'pos' in self
.child
.allParams
:
892 self
.child
.allParams
= self
.child
.allParams
[:]
893 self
.child
.allParams
.remove('pos')
894 if 'size' in self
.child
.allParams
:
895 self
.child
.allParams
= self
.child
.allParams
[:]
896 self
.child
.allParams
.remove('size')
898 class xxxSpacer(xxxObject
):
899 hasName
= hasStyle
= False
900 allParams
= ['size', 'option', 'flag', 'border']
901 paramDict
= {'option': ParamInt}
902 default
= {'size': '0,0'}
903 def __init__(self
, parent
, element
, refElem
=None):
904 # For GridBag sizer items, extra parameters added
905 if isinstance(parent
, xxxGridBagSizer
):
906 self
.allParams
= self
.allParams
+ ['cellpos', 'cellspan']
907 xxxObject
.__init
__(self
, parent
, element
, refElem
)
909 class xxxMenuBar(xxxContainer
):
910 allParams
= ['style']
911 paramDict
= {'style': ParamNonGenericStyle}
# no generic styles
912 winStyles
= ['wxMB_DOCKABLE']
914 class xxxMenu(xxxContainer
):
915 allParams
= ['label', 'help', 'style']
916 default
= {'label': ''}
917 paramDict
= {'style': ParamNonGenericStyle}
# no generic styles
918 winStyles
= ['wxMENU_TEAROFF']
920 class xxxMenuItem(xxxObject
):
921 allParams
= ['label', 'bitmap', 'accel', 'help',
922 'checkable', 'radio', 'enabled', 'checked']
923 default
= {'label': ''}
926 class xxxSeparator(xxxObject
):
927 hasName
= hasStyle
= False
929 ################################################################################
932 class xxxUnknown(xxxObject
):
933 allParams
= ['pos', 'size', 'style']
934 winStyles
= ['wxNO_FULL_REPAINT_ON_RESIZE']
936 ################################################################################
939 _handlers
= [] # custom handler classes/funcs
942 def setHandlers(handlers
):
945 _CFuncPtr
= None # ctypes function type
948 """Register hndlr function or XmlResourceHandler class."""
949 if _CFuncPtr
and isinstance(hndlr
, _CFuncPtr
):
950 _handlers
.append(hndlr
)
952 if not isinstance(hndlr
, type):
953 wx
.LogError('handler is not a type: %s' % hndlr
)
954 elif not issubclass(hndlr
, wx
.xrc
.XmlResourceHandler
):
955 wx
.LogError('handler is not a XmlResourceHandler: %s' % hndlr
)
957 _handlers
.append(hndlr
)
959 def load_dl(path
, localname
=''):
960 """Load shared/dynamic library into xxx namespace.
962 If path is not absolute or relative, try to find in the module's directory.
965 localname
= os
.path
.basename(os
.path
.splitext(path
)[0])
969 _CFuncPtr
= ctypes
._CFuncPtr
# use as a flag of loaded ctypes
970 #if not os.path.dirname(path) and os.path.isfile(path):
973 wx
.LogError('ctypes module not found')
974 globals()[localname
] = None
977 dl
= ctypes
.CDLL(path
)
978 globals()[localname
] = dl
979 # Register AddXmlHandlers() if exists
981 register(dl
.AddXmlHandlers
)
985 wx
.LogError('error loading dynamic library: %s' % path
)
986 print traceback
.print_exc()
988 # Called when creating test window
991 if _CFuncPtr
and isinstance(h
, _CFuncPtr
):
995 wx
.LogError('error calling DL func: "%s"' % h
)
996 print traceback
.print_exc()
999 xrc
.XmlResource
.Get().AddHandler(apply(h
, ()))
1001 wx
.LogError('error adding XmlHandler: "%s"' % h
)
1002 print traceback
.print_exc()
1004 def custom(klassName
, klass
='unknown'):
1005 """Define custom control based on xrcClass.
1007 klass: new object name
1008 xrcClass: name of an existing XRC object class or
1009 a class object defining class parameters.
1011 if type(klass
) is str:
1012 # Copy correct xxx class under new name
1014 xxxClass
= types
.ClassType('xxx' + klassName
, kl
.__bases
__, kl
.__dict
__)
1017 # Register param IDs
1018 for param
in klass
.allParams
+ klass
.paramDict
.keys():
1019 if not paramIDs
.has_key(param
):
1020 paramIDs
[param
] = wx
.NewId()
1021 # Insert in dictionaty
1022 xxxDict
[klassName
] = xxxClass
1024 g
.pullDownMenu
.addCustom(klassName
)
1026 class xxxParamComment(xxxParam
):
1027 def __init__(self
, node
):
1028 xxxNode
.__init
__(self
, node
)
1029 self
.textNode
= node
1030 # Parse "pragma" comments
1031 if node
.data
and node
.data
[0] == '%':
1033 code
= node
.data
[1:]
1034 exec code
in globals()
1036 wx
.LogError('exec error: "%s"' % code
)
1037 print traceback
.print_exc()
1039 class xxxComment(xxxObject
):
1040 hasStyle
= hasName
= False
1041 allParams
= required
= ['comment']
1043 def __init__(self
, parent
, node
):
1044 self
.parent
= parent
1046 self
.isElement
= False
1048 self
.className
= 'comment'
1049 self
.ref
= self
.subclass
= None
1050 self
.params
= {'comment': xxxParamComment(node)}
1053 # Replace newlines by \n to avoid tree item resizing
1054 return self
.params
['comment'].value().replace('\n', r
'\n')
1056 ################################################################################
1058 # Mapping of XRC names to xxx classes
1060 'wxPanel': xxxPanel
,
1061 'wxDialog': xxxDialog
,
1062 'wxFrame': xxxFrame
,
1064 'wxToolBar': xxxToolBar
,
1065 'wxStatusBar': xxxStatusBar
,
1066 'wxWizard': xxxWizard
,
1067 'wxWizardPage': xxxWizardPage
,
1068 'wxWizardPageSimple': xxxWizardPageSimple
,
1070 'wxBitmap': xxxBitmap
,
1073 'wxButton': xxxButton
,
1074 'wxBitmapButton': xxxBitmapButton
,
1075 'wxRadioButton': xxxRadioButton
,
1076 'wxSpinButton': xxxSpinButton
,
1077 'wxToggleButton' : xxxToggleButton
,
1079 'wxStaticBox': xxxStaticBox
,
1080 'wxStaticBitmap': xxxStaticBitmap
,
1081 'wxRadioBox': xxxRadioBox
,
1082 'wxComboBox': xxxComboBox
,
1083 'wxCheckBox': xxxCheckBox
,
1084 'wxListBox': xxxListBox
,
1086 'wxStaticText': xxxStaticText
,
1087 'wxStaticLine': xxxStaticLine
,
1088 'wxTextCtrl': xxxTextCtrl
,
1089 'wxChoice': xxxChoice
,
1090 'wxSlider': xxxSlider
,
1091 'wxGauge': xxxGauge
,
1092 'wxScrollBar': xxxScrollBar
,
1093 'wxTreeCtrl': xxxTreeCtrl
,
1094 'wxListCtrl': xxxListCtrl
,
1095 'wxCheckListBox': xxxCheckList
,
1096 'notebookpage': xxxPage
,
1097 'choicebookpage': xxxPage
,
1098 'listbookpage': xxxPage
,
1099 'wxNotebook': xxxNotebook
,
1100 'wxChoicebook': xxxChoicebook
,
1101 'wxListbook': xxxListbook
,
1102 'wxSplitterWindow': xxxSplitterWindow
,
1103 'wxHtmlWindow': xxxHtmlWindow
,
1104 'wxCalendarCtrl': xxxCalendarCtrl
,
1105 'wxGenericDirCtrl': xxxGenericDirCtrl
,
1106 'wxSpinCtrl': xxxSpinCtrl
,
1107 'wxScrolledWindow': xxxScrolledWindow
,
1109 'wxFilePickerCtrl': xxxFilePickerCtrl
,
1110 'wxDatePickerCtrl': xxxDateCtrl
,
1112 'wxBoxSizer': xxxBoxSizer
,
1113 'wxStaticBoxSizer': xxxStaticBoxSizer
,
1114 'wxGridSizer': xxxGridSizer
,
1115 'wxFlexGridSizer': xxxFlexGridSizer
,
1116 'wxGridBagSizer': xxxGridBagSizer
,
1117 'wxStdDialogButtonSizer': xxxStdDialogButtonSizer
,
1118 'sizeritem': xxxSizerItem
, 'button': xxxSizerItemButton
,
1119 'spacer': xxxSpacer
,
1121 'wxMenuBar': xxxMenuBar
,
1123 'wxMenuItem': xxxMenuItem
,
1124 'separator': xxxSeparator
,
1126 'unknown': xxxUnknown
,
1127 'comment': xxxComment
,
1130 # Create IDs for all parameters of all classes
1131 paramIDs
= {'fg': wx
.NewId(), 'bg': wx
.NewId(), 'exstyle': wx
.NewId(), 'font': wx
.NewId(),
1132 'enabled': wx
.NewId(), 'focused': wx
.NewId(), 'hidden': wx
.NewId(),
1133 'tooltip': wx
.NewId(), 'encoding': wx
.NewId(),
1134 'cellpos': wx
.NewId(), 'cellspan': wx
.NewId(),
1137 for cl
in xxxDict
.values():
1139 for param
in cl
.allParams
+ cl
.paramDict
.keys():
1140 if not paramIDs
.has_key(param
):
1141 paramIDs
[param
] = wx
.NewId()
1143 ################################################################################
1146 # Test for object elements
1148 return node
.nodeType
== minidom
.Node
.ELEMENT_NODE
and \
1149 node
.tagName
in ['object', 'object_ref'] or \
1150 node
.nodeType
== minidom
.Node
.COMMENT_NODE
1152 # Make XXX object from some DOM object, selecting correct class
1153 def MakeXXXFromDOM(parent
, node
):
1154 if node
.nodeType
== minidom
.Node
.COMMENT_NODE
:
1155 return xxxComment(parent
, node
)
1156 if node
.tagName
== 'object_ref':
1157 ref
= node
.getAttribute('ref')
1158 refElem
= FindResource(ref
)
1159 if refElem
: cls
= refElem
.getAttribute('class')
1160 else: return xxxUnknown(parent
, node
)
1163 cls
= node
.getAttribute('class')
1165 klass
= xxxDict
[cls
]
1167 # If we encounter a weird class, use unknown template
1168 print 'WARNING: unsupported class:', node
.getAttribute('class')
1170 return klass(parent
, node
, refElem
)
1172 # Make empty DOM element
1173 def MakeEmptyDOM(className
):
1174 elem
= g
.tree
.dom
.createElement('object')
1175 elem
.setAttribute('class', className
)
1176 # Set required and default parameters
1177 xxxClass
= xxxDict
[className
]
1178 defaultNotRequired
= filter(lambda x
, l
=xxxClass
.required
: x
not in l
,
1179 xxxClass
.default
.keys())
1180 for param
in xxxClass
.required
+ defaultNotRequired
:
1181 textElem
= g
.tree
.dom
.createElement(param
)
1183 textNode
= g
.tree
.dom
.createTextNode(xxxClass
.default
[param
])
1185 textNode
= g
.tree
.dom
.createTextNode('')
1186 textElem
.appendChild(textNode
)
1187 elem
.appendChild(textElem
)
1190 # Make empty XXX object
1191 def MakeEmptyXXX(parent
, className
):
1192 # Make corresponding DOM object first
1193 elem
= MakeEmptyDOM(className
)
1194 # If parent is a sizer, we should create sizeritem object, except for spacers
1196 if parent
.isSizer
and className
!= 'spacer':
1197 sizerItemElem
= MakeEmptyDOM(parent
.itemTag
)
1198 sizerItemElem
.appendChild(elem
)
1199 elem
= sizerItemElem
1200 elif isinstance(parent
, xxxNotebook
):
1201 pageElem
= MakeEmptyDOM('notebookpage')
1202 pageElem
.appendChild(elem
)
1204 elif isinstance(parent
, xxxChoicebook
):
1205 pageElem
= MakeEmptyDOM('choicebookpage')
1206 pageElem
.appendChild(elem
)
1208 elif isinstance(parent
, xxxListbook
):
1209 pageElem
= MakeEmptyDOM('listbookpage')
1210 pageElem
.appendChild(elem
)
1212 # Now just make object
1213 return MakeXXXFromDOM(parent
, elem
)
1215 # Make empty DOM element for reference
1216 def MakeEmptyRefDOM(ref
):
1217 elem
= g
.tree
.dom
.createElement('object_ref')
1218 elem
.setAttribute('ref', ref
)
1221 # Make empty XXX object
1222 def MakeEmptyRefXXX(parent
, ref
):
1223 # Make corresponding DOM object first
1224 elem
= MakeEmptyRefDOM(ref
)
1225 # If parent is a sizer, we should create sizeritem object, except for spacers
1228 sizerItemElem
= MakeEmptyDOM(parent
.itemTag
)
1229 sizerItemElem
.appendChild(elem
)
1230 elem
= sizerItemElem
1231 elif isinstance(parent
, xxxNotebook
):
1232 pageElem
= MakeEmptyDOM('notebookpage')
1233 pageElem
.appendChild(elem
)
1235 elif isinstance(parent
, xxxChoicebook
):
1236 pageElem
= MakeEmptyDOM('choicebookpage')
1237 pageElem
.appendChild(elem
)
1239 elif isinstance(parent
, xxxListbook
):
1240 pageElem
= MakeEmptyDOM('listbookpage')
1241 pageElem
.appendChild(elem
)
1243 # Now just make object
1244 xxx
= MakeXXXFromDOM(parent
, elem
)
1245 # Label is not used for references
1246 xxx
.allParams
= xxx
.allParams
[:]
1247 #xxx.allParams.remove('label')
1250 # Make empty comment node
1251 def MakeEmptyCommentDOM():
1252 node
= g
.tree
.dom
.createComment('')
1255 # Make empty xxxComment
1256 def MakeEmptyCommentXXX(parent
):
1257 node
= MakeEmptyCommentDOM()
1258 # Now just make object
1259 xxx
= MakeXXXFromDOM(parent
, node
)