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():
863 elif isinstance(self
.child
, xxxObject
):
864 for param
,v
in self
.defaults_control
.items():
866 def resetChild(self
, xxx
):
867 xxxChildContainer
.resetChild(self
, xxx
)
868 # Remove pos parameter - not needed for sizeritems
869 if 'pos' in self
.child
.allParams
:
870 self
.child
.allParams
= self
.child
.allParams
[:]
871 self
.child
.allParams
.remove('pos')
873 class xxxSizerItemButton(xxxSizerItem
):
876 def __init__(self
, parent
, element
, refElem
=None):
877 xxxChildContainer
.__init
__(self
, parent
, element
, refElem
=None)
878 # Remove pos parameter - not needed for sizeritems
879 if 'pos' in self
.child
.allParams
:
880 self
.child
.allParams
= self
.child
.allParams
[:]
881 self
.child
.allParams
.remove('pos')
883 class xxxPage(xxxChildContainer
):
884 allParams
= ['label', 'selected']
885 paramDict
= {'selected': ParamBool}
887 def __init__(self
, parent
, element
, refElem
=None):
888 xxxChildContainer
.__init
__(self
, parent
, element
, refElem
)
889 # pos and size dont matter for notebookpages
890 if 'pos' in self
.child
.allParams
:
891 self
.child
.allParams
= self
.child
.allParams
[:]
892 self
.child
.allParams
.remove('pos')
893 if 'size' in self
.child
.allParams
:
894 self
.child
.allParams
= self
.child
.allParams
[:]
895 self
.child
.allParams
.remove('size')
897 class xxxSpacer(xxxObject
):
898 hasName
= hasStyle
= False
899 allParams
= ['size', 'option', 'flag', 'border']
900 paramDict
= {'option': ParamInt}
901 default
= {'size': '0,0'}
902 def __init__(self
, parent
, element
, refElem
=None):
903 # For GridBag sizer items, extra parameters added
904 if isinstance(parent
, xxxGridBagSizer
):
905 self
.allParams
= self
.allParams
+ ['cellpos', 'cellspan']
906 xxxObject
.__init
__(self
, parent
, element
, refElem
)
908 class xxxMenuBar(xxxContainer
):
909 allParams
= ['style']
910 paramDict
= {'style': ParamNonGenericStyle}
# no generic styles
911 winStyles
= ['wxMB_DOCKABLE']
913 class xxxMenu(xxxContainer
):
914 allParams
= ['label', 'help', 'style']
915 default
= {'label': ''}
916 paramDict
= {'style': ParamNonGenericStyle}
# no generic styles
917 winStyles
= ['wxMENU_TEAROFF']
919 class xxxMenuItem(xxxObject
):
920 allParams
= ['label', 'bitmap', 'accel', 'help',
921 'checkable', 'radio', 'enabled', 'checked']
922 default
= {'label': ''}
925 class xxxSeparator(xxxObject
):
926 hasName
= hasStyle
= False
928 ################################################################################
931 class xxxUnknown(xxxObject
):
932 allParams
= ['pos', 'size', 'style']
933 winStyles
= ['wxNO_FULL_REPAINT_ON_RESIZE']
935 ################################################################################
938 _handlers
= [] # custom handler classes/funcs
941 def setHandlers(handlers
):
944 _CFuncPtr
= None # ctypes function type
947 """Register hndlr function or XmlResourceHandler class."""
948 if _CFuncPtr
and isinstance(hndlr
, _CFuncPtr
):
949 _handlers
.append(hndlr
)
951 if not isinstance(hndlr
, type):
952 wx
.LogError('handler is not a type: %s' % hndlr
)
953 elif not issubclass(hndlr
, wx
.xrc
.XmlResourceHandler
):
954 wx
.LogError('handler is not a XmlResourceHandler: %s' % hndlr
)
956 _handlers
.append(hndlr
)
958 def load_dl(path
, localname
=''):
959 """Load shared/dynamic library into xxx namespace.
961 If path is not absolute or relative, try to find in the module's directory.
964 localname
= os
.path
.basename(os
.path
.splitext(path
)[0])
968 _CFuncPtr
= ctypes
._CFuncPtr
# use as a flag of loaded ctypes
969 #if not os.path.dirname(path) and os.path.isfile(path):
972 wx
.LogError('ctypes module not found')
973 globals()[localname
] = None
976 dl
= ctypes
.CDLL(path
)
977 globals()[localname
] = dl
978 # Register AddXmlHandlers() if exists
980 register(dl
.AddXmlHandlers
)
984 wx
.LogError('error loading dynamic library: %s' % path
)
985 print traceback
.print_exc()
987 # Called when creating test window
990 if _CFuncPtr
and isinstance(h
, _CFuncPtr
):
994 wx
.LogError('error calling DL func: "%s"' % h
)
995 print traceback
.print_exc()
998 xrc
.XmlResource
.Get().AddHandler(apply(h
, ()))
1000 wx
.LogError('error adding XmlHandler: "%s"' % h
)
1001 print traceback
.print_exc()
1003 def custom(klassName
, klass
='unknown'):
1004 """Define custom control based on xrcClass.
1006 klass: new object name
1007 xrcClass: name of an existing XRC object class or
1008 a class object defining class parameters.
1010 if type(klass
) is str:
1011 # Copy correct xxx class under new name
1013 xxxClass
= types
.ClassType('xxx' + klassName
, kl
.__bases
__, kl
.__dict
__)
1016 # Register param IDs
1017 for param
in klass
.allParams
+ klass
.paramDict
.keys():
1018 if not paramIDs
.has_key(param
):
1019 paramIDs
[param
] = wx
.NewId()
1020 # Insert in dictionaty
1021 xxxDict
[klassName
] = xxxClass
1023 g
.pullDownMenu
.addCustom(klassName
)
1025 class xxxParamComment(xxxParam
):
1026 locals = {} # namespace for comment directives
1027 allow
= None # undefined initial state for current file
1028 def __init__(self
, node
):
1029 xxxNode
.__init
__(self
, node
)
1030 self
.textNode
= node
1031 # Parse "pragma" comments if enabled
1032 if node
.data
and node
.data
[0] == '%' and g
.conf
.allowExec
!= 'no' and \
1033 xxxParamComment
.allow
is not False:
1035 if g
.conf
.allowExec
== 'ask' and xxxParamComment
.allow
is None:
1036 flags
= wx
.ICON_EXCLAMATION | wx
.YES_NO | wx
.CENTRE
1037 dlg
= wx
.MessageDialog(g
.frame
, '''
1038 This file contains executable %comment directives. Allow to execute?''',
1040 say
= dlg
.ShowModal()
1042 if say
== wx
.ID_YES
:
1043 xxxParamComment
.allow
= True
1045 xxxParamComment
.allow
= False
1047 code
= node
.data
[1:]
1048 exec code
in globals(), self
.locals
1050 wx
.LogError('exec error: "%s"' % code
)
1051 print traceback
.print_exc()
1053 class xxxComment(xxxObject
):
1054 hasStyle
= hasName
= False
1055 allParams
= required
= ['comment']
1057 def __init__(self
, parent
, node
):
1058 self
.parent
= parent
1060 self
.isElement
= False
1062 self
.className
= 'comment'
1063 self
.ref
= self
.subclass
= None
1064 self
.params
= {'comment': xxxParamComment(node)}
1067 # Replace newlines by \n to avoid tree item resizing
1068 return self
.params
['comment'].value().replace('\n', r
'\n')
1070 ################################################################################
1072 # Mapping of XRC names to xxx classes
1074 'wxPanel': xxxPanel
,
1075 'wxDialog': xxxDialog
,
1076 'wxFrame': xxxFrame
,
1078 'wxToolBar': xxxToolBar
,
1079 'wxStatusBar': xxxStatusBar
,
1080 'wxWizard': xxxWizard
,
1081 'wxWizardPage': xxxWizardPage
,
1082 'wxWizardPageSimple': xxxWizardPageSimple
,
1084 'wxBitmap': xxxBitmap
,
1087 'wxButton': xxxButton
,
1088 'wxBitmapButton': xxxBitmapButton
,
1089 'wxRadioButton': xxxRadioButton
,
1090 'wxSpinButton': xxxSpinButton
,
1091 'wxToggleButton' : xxxToggleButton
,
1093 'wxStaticBox': xxxStaticBox
,
1094 'wxStaticBitmap': xxxStaticBitmap
,
1095 'wxRadioBox': xxxRadioBox
,
1096 'wxComboBox': xxxComboBox
,
1097 'wxCheckBox': xxxCheckBox
,
1098 'wxListBox': xxxListBox
,
1100 'wxStaticText': xxxStaticText
,
1101 'wxStaticLine': xxxStaticLine
,
1102 'wxTextCtrl': xxxTextCtrl
,
1103 'wxChoice': xxxChoice
,
1104 'wxSlider': xxxSlider
,
1105 'wxGauge': xxxGauge
,
1106 'wxScrollBar': xxxScrollBar
,
1107 'wxTreeCtrl': xxxTreeCtrl
,
1108 'wxListCtrl': xxxListCtrl
,
1109 'wxCheckListBox': xxxCheckList
,
1110 'notebookpage': xxxPage
,
1111 'choicebookpage': xxxPage
,
1112 'listbookpage': xxxPage
,
1113 'wxNotebook': xxxNotebook
,
1114 'wxChoicebook': xxxChoicebook
,
1115 'wxListbook': xxxListbook
,
1116 'wxSplitterWindow': xxxSplitterWindow
,
1117 'wxHtmlWindow': xxxHtmlWindow
,
1118 'wxCalendarCtrl': xxxCalendarCtrl
,
1119 'wxGenericDirCtrl': xxxGenericDirCtrl
,
1120 'wxSpinCtrl': xxxSpinCtrl
,
1121 'wxScrolledWindow': xxxScrolledWindow
,
1123 'wxFilePickerCtrl': xxxFilePickerCtrl
,
1124 'wxDatePickerCtrl': xxxDateCtrl
,
1126 'wxBoxSizer': xxxBoxSizer
,
1127 'wxStaticBoxSizer': xxxStaticBoxSizer
,
1128 'wxGridSizer': xxxGridSizer
,
1129 'wxFlexGridSizer': xxxFlexGridSizer
,
1130 'wxGridBagSizer': xxxGridBagSizer
,
1131 'wxStdDialogButtonSizer': xxxStdDialogButtonSizer
,
1132 'sizeritem': xxxSizerItem
, 'button': xxxSizerItemButton
,
1133 'spacer': xxxSpacer
,
1135 'wxMenuBar': xxxMenuBar
,
1137 'wxMenuItem': xxxMenuItem
,
1138 'separator': xxxSeparator
,
1140 'unknown': xxxUnknown
,
1141 'comment': xxxComment
,
1144 # Create IDs for all parameters of all classes
1145 paramIDs
= {'fg': wx
.NewId(), 'bg': wx
.NewId(), 'exstyle': wx
.NewId(), 'font': wx
.NewId(),
1146 'enabled': wx
.NewId(), 'focused': wx
.NewId(), 'hidden': wx
.NewId(),
1147 'tooltip': wx
.NewId(), 'encoding': wx
.NewId(),
1148 'cellpos': wx
.NewId(), 'cellspan': wx
.NewId(),
1151 for cl
in xxxDict
.values():
1153 for param
in cl
.allParams
+ cl
.paramDict
.keys():
1154 if not paramIDs
.has_key(param
):
1155 paramIDs
[param
] = wx
.NewId()
1157 ################################################################################
1160 # Test for object elements
1162 return node
.nodeType
== minidom
.Node
.ELEMENT_NODE
and \
1163 node
.tagName
in ['object', 'object_ref'] or \
1164 node
.nodeType
== minidom
.Node
.COMMENT_NODE
1166 # Make XXX object from some DOM object, selecting correct class
1167 def MakeXXXFromDOM(parent
, node
):
1168 if node
.nodeType
== minidom
.Node
.COMMENT_NODE
:
1169 return xxxComment(parent
, node
)
1170 if node
.tagName
== 'object_ref':
1171 ref
= node
.getAttribute('ref')
1172 refElem
= FindResource(ref
)
1173 if refElem
: cls
= refElem
.getAttribute('class')
1174 else: return xxxUnknown(parent
, node
)
1177 cls
= node
.getAttribute('class')
1179 klass
= xxxDict
[cls
]
1181 # If we encounter a weird class, use unknown template
1182 print 'WARNING: unsupported class:', node
.getAttribute('class')
1184 return klass(parent
, node
, refElem
)
1186 # Make empty DOM element
1187 def MakeEmptyDOM(className
):
1188 elem
= g
.tree
.dom
.createElement('object')
1189 elem
.setAttribute('class', className
)
1190 # Set required and default parameters
1191 xxxClass
= xxxDict
[className
]
1192 defaultNotRequired
= filter(lambda x
, l
=xxxClass
.required
: x
not in l
,
1193 xxxClass
.default
.keys())
1194 for param
in xxxClass
.required
+ defaultNotRequired
:
1195 textElem
= g
.tree
.dom
.createElement(param
)
1197 textNode
= g
.tree
.dom
.createTextNode(xxxClass
.default
[param
])
1199 textNode
= g
.tree
.dom
.createTextNode('')
1200 textElem
.appendChild(textNode
)
1201 elem
.appendChild(textElem
)
1204 # Make empty XXX object
1205 def MakeEmptyXXX(parent
, className
):
1206 # Make corresponding DOM object first
1207 elem
= MakeEmptyDOM(className
)
1208 # If parent is a sizer, we should create sizeritem object, except for spacers
1210 if parent
.isSizer
and className
!= 'spacer':
1211 sizerItemElem
= MakeEmptyDOM(parent
.itemTag
)
1212 sizerItemElem
.appendChild(elem
)
1213 elem
= sizerItemElem
1214 elif isinstance(parent
, xxxNotebook
):
1215 pageElem
= MakeEmptyDOM('notebookpage')
1216 pageElem
.appendChild(elem
)
1218 elif isinstance(parent
, xxxChoicebook
):
1219 pageElem
= MakeEmptyDOM('choicebookpage')
1220 pageElem
.appendChild(elem
)
1222 elif isinstance(parent
, xxxListbook
):
1223 pageElem
= MakeEmptyDOM('listbookpage')
1224 pageElem
.appendChild(elem
)
1226 # Now just make object
1227 return MakeXXXFromDOM(parent
, elem
)
1229 # Make empty DOM element for reference
1230 def MakeEmptyRefDOM(ref
):
1231 elem
= g
.tree
.dom
.createElement('object_ref')
1232 elem
.setAttribute('ref', ref
)
1235 # Make empty XXX object
1236 def MakeEmptyRefXXX(parent
, ref
):
1237 # Make corresponding DOM object first
1238 elem
= MakeEmptyRefDOM(ref
)
1239 # If parent is a sizer, we should create sizeritem object, except for spacers
1242 sizerItemElem
= MakeEmptyDOM(parent
.itemTag
)
1243 sizerItemElem
.appendChild(elem
)
1244 elem
= sizerItemElem
1245 elif isinstance(parent
, xxxNotebook
):
1246 pageElem
= MakeEmptyDOM('notebookpage')
1247 pageElem
.appendChild(elem
)
1249 elif isinstance(parent
, xxxChoicebook
):
1250 pageElem
= MakeEmptyDOM('choicebookpage')
1251 pageElem
.appendChild(elem
)
1253 elif isinstance(parent
, xxxListbook
):
1254 pageElem
= MakeEmptyDOM('listbookpage')
1255 pageElem
.appendChild(elem
)
1257 # Now just make object
1258 xxx
= MakeXXXFromDOM(parent
, elem
)
1259 # Label is not used for references
1260 xxx
.allParams
= xxx
.allParams
[:]
1261 #xxx.allParams.remove('label')
1264 # Make empty comment node
1265 def MakeEmptyCommentDOM():
1266 node
= g
.tree
.dom
.createComment('')
1269 # Make empty xxxComment
1270 def MakeEmptyCommentXXX(parent
):
1271 node
= MakeEmptyCommentDOM()
1272 # Now just make object
1273 xxx
= MakeXXXFromDOM(parent
, node
)