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 wxPython
.wx 
import * 
   8 from wxPython
.xrc 
import * 
   9 from xml
.dom 
import minidom
 
  10 import wxPython
.lib
.wxpTag
 
  14 # Base class for interface parameter classes 
  16     def __init__(self
, node
): 
  19         self
.node
.parentNode
.removeChild(self
.node
) 
  22 # Generic (text) parameter class 
  23 class xxxParam(xxxNode
): 
  24     # Standard use: for text nodes 
  25     def __init__(self
, node
): 
  26         xxxNode
.__init
__(self
, node
) 
  27         if not node
.hasChildNodes(): 
  28             # If does not have child nodes, create empty text node 
  29             text 
= tree
.dom
.createTextNode('') 
  30             node
.appendChild(text
) 
  32             text 
= node
.childNodes
[0] # first child must be text node 
  33             assert text
.nodeType 
== minidom
.Node
.TEXT_NODE
 
  35     # Value returns string 
  37         return self
.textNode
.data
 
  38     def update(self
, value
): 
  39         self
.textNode
.data 
= value
 
  42 class xxxParamInt(xxxParam
): 
  43     # Standard use: for text nodes 
  44     def __init__(self
, node
): 
  45         xxxParam
.__init
__(self
, node
) 
  46     # Value returns string 
  49             return int(self
.textNode
.data
) 
  51             return -1                   # invalid value 
  52     def update(self
, value
): 
  53         self
.textNode
.data 
= str(value
) 
  56 class xxxParamContent(xxxNode
): 
  57     def __init__(self
, node
): 
  58         xxxNode
.__init
__(self
, node
) 
  59         data
, l 
= [], []                # data is needed to quicker value retrieval 
  60         nodes 
= node
.childNodes
[:]      # make a copy of the child list 
  62             if n
.nodeType 
== minidom
.Node
.ELEMENT_NODE
: 
  63                 assert n
.tagName 
== 'item', 'bad content content' 
  64                 if not n
.hasChildNodes(): 
  65                     # If does not have child nodes, create empty text node 
  66                     text 
= tree
.dom
.createTextNode('') 
  67                     node
.appendChild(text
) 
  70                     text 
= n
.childNodes
[0] # first child must be text node 
  71                     assert text
.nodeType 
== minidom
.Node
.TEXT_NODE
 
  73                 data
.append(str(text
.data
)) 
  77         self
.l
, self
.data 
= l
, data
 
  80     def update(self
, value
): 
  81         # If number if items is not the same, recreate children 
  82         if len(value
) != len(self
.l
):   # remove first if number of items has changed 
  83             childNodes 
= self
.node
.childNodes
[:] 
  85                 self
.node
.removeChild(n
) 
  88                 itemElem 
= tree
.dom
.createElement('item') 
  89                 itemText 
= tree
.dom
.createTextNode(str) 
  90                 itemElem
.appendChild(itemText
) 
  91                 self
.node
.appendChild(itemElem
) 
  95             for i 
in range(len(value
)): 
  96                 self
.l
[i
].data 
= value
[i
] 
  99 # Content parameter for checklist 
 100 class xxxParamContentCheckList(xxxNode
): 
 101     def __init__(self
, node
): 
 102         xxxNode
.__init
__(self
, node
) 
 103         data
, l 
= [], []                # data is needed to quicker value retrieval 
 104         nodes 
= node
.childNodes
[:]      # make a copy of the child list 
 106             if n
.nodeType 
== minidom
.Node
.ELEMENT_NODE
: 
 107                 assert n
.tagName 
== 'item', 'bad content content' 
 108                 checked 
= n
.getAttribute('checked') 
 109                 if not n
.hasChildNodes(): 
 110                     # If does not have child nodes, create empty text node 
 111                     text 
= tree
.dom
.createTextNode('') 
 112                     node
.appendChild(text
) 
 115                     text 
= n
.childNodes
[0] # first child must be text node 
 116                     assert text
.nodeType 
== minidom
.Node
.TEXT_NODE
 
 118                 data
.append((str(text
.data
), int(checked
))) 
 122         self
.l
, self
.data 
= l
, data
 
 125     def update(self
, value
): 
 126         # If number if items is not the same, recreate children 
 127         if len(value
) != len(self
.l
):   # remove first if number of items has changed 
 128             childNodes 
= self
.node
.childNodes
[:] 
 130                 self
.node
.removeChild(n
) 
 133                 itemElem 
= tree
.dom
.createElement('item') 
 134                 itemElem
.setAttribute('checked', str(ch
)) 
 135                 itemText 
= tree
.dom
.createTextNode(s
) 
 136                 itemElem
.appendChild(itemText
) 
 137                 self
.node
.appendChild(itemElem
) 
 138                 l
.append((itemText
, itemElem
)) 
 141             for i 
in range(len(value
)): 
 142                 self
.l
[i
][0].data 
= value
[i
][0] 
 143                 self
.l
[i
][1].setAttribute('checked', str(value
[i
][1])) 
 146 ################################################################################ 
 148 # Classes to interface DOM objects 
 151     hasChildren 
= false                 
# has children elements? 
 152     hasStyle 
= true                     
# almost everyone 
 153     hasName 
= true                      
# has name attribute? 
 154     isSizer 
= hasChild 
= false
 
 155     allParams 
= None                    # Some nodes have no parameters 
 156     # Style parameters (all optional) 
 157     styles 
= ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'tooltip'] 
 160     # Required paremeters: none by default 
 162     # Default parameters with default values 
 166     # Window styles and extended styles 
 170     # Construct a new xxx object from DOM element 
 171     # parent is parent xxx object (or None if none), element is DOM element object 
 172     def __init__(self
, parent
, element
): 
 174         self
.element 
= element
 
 177         self
.className 
= element
.getAttribute('class') 
 178         if self
.hasName
: self
.name 
= element
.getAttribute('name') 
 179         # Set parameters (text element children) 
 181         nodes 
= element
.childNodes
[:] 
 183             if node
.nodeType 
== minidom
.Node
.ELEMENT_NODE
: 
 186                     continue            # do nothing for object children here 
 187                 if not tag 
in self
.allParams 
and not tag 
in self
.styles
: 
 188                     print 'WARNING: unknown parameter for %s: %s' % \
 
 189                           (self
.className
, tag
) 
 190                 elif tag 
in self
.specials
: 
 191                     self
.special(tag
, node
) 
 192                 elif tag 
== 'content': 
 193                     if self
.className 
== 'wxCheckList': 
 194                         self
.params
[tag
] = xxxParamContentCheckList(node
) 
 196                         self
.params
[tag
] = xxxParamContent(node
) 
 197                 elif tag 
== 'font': # has children 
 198                     self
.params
[tag
] = xxxParamFont(element
, node
) 
 199                 else:                   # simple parameter 
 200                     self
.params
[tag
] = xxxParam(node
) 
 202                 # Remove all other nodes 
 203                 element
.removeChild(node
) 
 205     # Returns real tree object 
 206     def treeObject(self
): 
 207         if self
.hasChild
: return self
.child
 
 209     # Returns tree image index 
 211         if self
.hasChild
: return self
.child
.treeImage() 
 213     # Class name plus wx name 
 215         if self
.hasChild
: return self
.child
.treeName() 
 216         if self
.hasName 
and self
.name
: return self
.className 
+ ' "' + self
.name 
+ '"' 
 217         return self
.className
 
 219 ################################################################################ 
 221 # This is a little special: it is both xxxObject and xxxNode 
 222 class xxxParamFont(xxxObject
, xxxNode
): 
 223     allParams 
= ['size', 'style', 'weight', 'family', 'underlined', 
 225     def __init__(self
, parent
, element
): 
 226         xxxObject
.__init
__(self
, parent
, element
) 
 227         xxxNode
.__init
__(self
, element
) 
 228         self
.parentNode 
= parent       
# required to behave similar to DOM node 
 230         for p 
in self
.allParams
: 
 232                 v
.append(str(self
.params
[p
].value())) 
 236     def update(self
, value
): 
 237         # `value' is a list of strings corresponding to all parameters 
 239         # Remove old elements first 
 240         childNodes 
= elem
.childNodes
[:] 
 241         for node 
in childNodes
: elem
.removeChild(node
) 
 245         for param 
in self
.allParams
: 
 247                 fontElem 
= tree
.dom
.createElement(param
) 
 248                 textNode 
= tree
.dom
.createTextNode(value
[i
]) 
 249                 self
.params
[param
] = textNode
 
 250                 fontElem
.appendChild(textNode
) 
 251                 elem
.appendChild(fontElem
) 
 258 ################################################################################ 
 260 class xxxContainer(xxxObject
): 
 263 # Special class for root node 
 264 class xxxMainNode(xxxContainer
): 
 265     hasStyle 
= hasName 
= false
 
 267 ################################################################################ 
 270 class xxxPanel(xxxContainer
): 
 271     allParams 
= ['pos', 'size', 'style'] 
 272     styles 
= ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 
 274     winStyles 
= ['wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN'] 
 275     exStyles 
= ['wxWS_EX_VALIDATE_RECURSIVELY'] 
 277 class xxxDialog(xxxContainer
): 
 278     allParams 
= ['title', 'pos', 'size', 'style'] 
 280     winStyles 
= ['wxDEFAULT_DIALOG_STYLE', 'wxSTAY_ON_TOP', 
 281                  'wxDIALOG_MODAL', 'wxDIALOG_MODELESS', 
 282                  'wxCAPTION', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', 'wxRESIZE_BOX', 
 284                  'wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN'] 
 285     styles 
= ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 
 287     exStyles 
= ['wxWS_EX_VALIDATE_RECURSIVELY'] 
 289 class xxxFrame(xxxContainer
): 
 290     allParams 
= ['title', 'centered', 'pos', 'size', 'style'] 
 291     paramDict 
= {'centered': ParamBool}
 
 293     winStyles 
= ['wxDEFAULT_FRAME_STYLE', 'wxDEFAULT_DIALOG_STYLE', 
 295                  'wxCAPTION', 'wxSYSTEM_MENU', 'wxRESIZE_BORDER', 
 296                  'wxRESIZE_BOX', 'wxMINIMIZE_BOX', 'wxMAXIMIZE_BOX', 
 297                  'wxFRAME_FLOAT_ON_PARENT', 'wxFRAME_TOOL_WINDOW', 
 298                  'wxNO_3D', 'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN'] 
 299     styles 
= ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 
 301     exStyles 
= ['wxWS_EX_VALIDATE_RECURSIVELY'] 
 303 class xxxTool(xxxObject
): 
 304     allParams 
= ['bitmap', 'bitmap2', 'toggle', 'tooltip', 'longhelp'] 
 305     paramDict 
= {'bitmap2': ParamFile}
 
 308 class xxxToolBar(xxxContainer
): 
 309     allParams 
= ['bitmapsize', 'margins', 'packing', 'separation',  
 310                  'pos', 'size', 'style'] 
 312     paramDict 
= {'bitmapsize': ParamPosSize
, 'margins': ParamPosSize
, 
 313                  'packing': ParamInt
, 'separation': ParamInt
, 
 314                  'style': ParamNonGenericStyle
} 
 315     winStyles 
= ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL'] 
 317 ################################################################################ 
 320 class xxxBitmap(xxxObject
): 
 321     allParams 
= ['bitmap'] 
 322     required 
= ['bitmap'] 
 324 class xxxIcon(xxxObject
): 
 328 ################################################################################ 
 331 class xxxStaticText(xxxObject
): 
 332     allParams 
= ['label', 'pos', 'size', 'style'] 
 334     winStyles 
= ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE'] 
 336 class xxxStaticLine(xxxObject
): 
 337     allParams 
= ['pos', 'size', 'style'] 
 338     winStyles 
= ['wxLI_HORIZONTAL', 'wxLI_VERTICAL'] 
 340 class xxxStaticBitmap(xxxObject
): 
 341     allParams 
= ['bitmap', 'pos', 'size', 'style'] 
 342     required 
= ['bitmap'] 
 344 class xxxTextCtrl(xxxObject
): 
 345     allParams 
= ['value', 'pos', 'size', 'style'] 
 346     winStyles 
= ['wxTE_PROCESS_ENTER', 'wxTE_PROCESS_TAB', 'wxTE_MULTILINE', 
 347               'wxTE_PASSWORD', 'wxTE_READONLY', 'wxHSCROLL'] 
 349 class xxxChoice(xxxObject
): 
 350     allParams 
= ['content', 'selection', 'pos', 'size', 'style'] 
 351     required 
= ['content'] 
 352     winStyles 
= ['wxCB_SORT'] 
 354 class xxxSlider(xxxObject
): 
 355     allParams 
= ['value', 'min', 'max', 'pos', 'size', 'style', 
 356                  'tickfreq', 'pagesize', 'linesize', 'thumb', 'tick', 
 358     paramDict 
= {'value': ParamInt
, 'tickfreq': ParamInt
, 'pagesize': ParamInt
, 
 359                  'linesize': ParamInt
, 'thumb': ParamInt
, 'thumb': ParamInt
, 
 360                  'tick': ParamInt
, 'selmin': ParamInt
, 'selmax': ParamInt
} 
 361     required 
= ['value', 'min', 'max'] 
 362     winStyles 
= ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS', 
 363                  'wxSL_LEFT', 'wxSL_RIGHT', 'wxSL_TOP', 'wxSL_BOTTOM', 
 364                  'wxSL_BOTH', 'wxSL_SELRANGE'] 
 366 class xxxGauge(xxxObject
): 
 367     allParams 
= ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel'] 
 368     paramDict 
= {'range': ParamInt
, 'value': ParamInt
, 
 369                  'shadow': ParamInt
, 'bezel': ParamInt
} 
 370     winStyles 
= ['wxGA_HORIZONTAL', 'wxGA_VERTICAL', 'wxGA_PROGRESSBAR', 'wxGA_SMOOTH'] 
 372 class xxxScrollBar(xxxObject
): 
 373     allParams 
= ['pos', 'size', 'style', 'value', 'thumbsize', 'range', 'pagesize'] 
 374     paramDict 
= {'value': ParamInt
, 'range': ParamInt
, 'thumbsize': ParamInt
, 
 375                  'pagesize': ParamInt
} 
 376     winStyles 
= ['wxSB_HORIZONTAL', 'wxSB_VERTICAL'] 
 378 class xxxListCtrl(xxxObject
): 
 379     allParams 
= ['pos', 'size', 'style'] 
 380     winStyles 
= ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON', 
 381               'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE', 
 382               'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER', 
 383               'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING'] 
 385 class xxxTreeCtrl(xxxObject
): 
 386     allParams 
= ['pos', 'size', 'style'] 
 387     winStyles 
= ['wxTR_HAS_BUTTONS', 'wxTR_NO_LINES', 'wxTR_LINES_AT_ROOT', 
 388               'wxTR_EDIT_LABELS', 'wxTR_MULTIPLE'] 
 390 class xxxHtmlWindow(xxxObject
): 
 391     allParams 
= ['pos', 'size', 'style', 'borders', 'url', 'htmlcode'] 
 392     paramDict 
= {'borders': ParamInt}
 
 393     winStyles 
= ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO'] 
 395 class xxxCalendar(xxxObject
): 
 396     allParams 
= ['pos', 'size', 'style'] 
 398 class xxxNotebook(xxxContainer
): 
 399     allParams 
= ['usenotebooksizer', 'pos', 'size', 'style'] 
 400     paramDict 
= {'usenotebooksizer': ParamBool}
 
 401     winStyles 
= ['wxNB_FIXEDWIDTH', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM'] 
 403 ################################################################################ 
 406 class xxxButton(xxxObject
): 
 407     allParams 
= ['label', 'default', 'pos', 'size', 'style'] 
 408     paramDict 
= {'default': ParamBool}
 
 410     winStyles 
= ['wxBU_LEFT', 'wxBU_TOP', 'wxBU_RIGHT', 'wxBU_BOTTOM'] 
 412 class xxxBitmapButton(xxxObject
): 
 413     allParams 
= ['bitmap', 'selected', 'focus', 'disabled', 'default', 
 414                  'pos', 'size', 'style'] 
 415     required 
= ['bitmap'] 
 416     winStyles 
= ['wxBU_AUTODRAW', 'wxBU_LEFT', 'wxBU_TOP', 
 417                  'wxBU_RIGHT', 'wxBU_BOTTOM'] 
 419 class xxxRadioButton(xxxObject
): 
 420     allParams 
= ['label', 'value', 'pos', 'size', 'style'] 
 421     paramDict 
= {'value': ParamBool}
 
 423     winStyles 
= ['wxRB_GROUP'] 
 425 class xxxSpinButton(xxxObject
): 
 426     allParams 
= ['pos', 'size', 'style'] 
 427     winStyles 
= ['wxSP_HORIZONTAL', 'wxSP_VERTICAL', 'wxSP_ARROW_KEYS', 'wxSP_WRAP'] 
 429 ################################################################################ 
 432 class xxxStaticBox(xxxObject
): 
 433     allParams 
= ['label', 'pos', 'size', 'style'] 
 436 class xxxRadioBox(xxxObject
): 
 437     allParams 
= ['label', 'content', 'selection', 'dimension', 'pos', 'size', 'style'] 
 438     paramDict 
= {'dimension': ParamInt}
 
 439     required 
= ['label', 'content'] 
 440     winStyles 
= ['wxRA_SPECIFY_ROWS', 'wxRA_SPECIFY_COLS'] 
 442 class xxxCheckBox(xxxObject
): 
 443     allParams 
= ['label', 'pos', 'size', 'style'] 
 446 class xxxComboBox(xxxObject
): 
 447     allParams 
= ['content', 'selection', 'value', 'pos', 'size', 'style'] 
 448     required 
= ['content'] 
 449     winStyles 
= ['wxCB_SIMPLE', 'wxCB_SORT', 'wxCB_READONLY', 'wxCB_DROPDOWN'] 
 451 class xxxListBox(xxxObject
): 
 452     allParams 
= ['content', 'selection', 'pos', 'size', 'style'] 
 453     required 
= ['content'] 
 454     winStyles 
= ['wxLB_SINGLE', 'wxLB_MULTIPLE', 'wxLB_EXTENDED', 'wxLB_HSCROLL', 
 455               'wxLB_ALWAYS_SB', 'wxLB_NEEDED_SB', 'wxLB_SORT'] 
 457 class xxxCheckList(xxxObject
): 
 458     allParams 
= ['content', 'pos', 'size', 'style'] 
 459     required 
= ['content'] 
 460     winStyles 
= ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON', 
 461               'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE', 
 462               'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER', 
 463               'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING'] 
 464     paramDict 
= {'content': ParamContentCheckList}
 
 466 ################################################################################ 
 469 class xxxSizer(xxxContainer
): 
 470     hasName 
= hasStyle 
= false
 
 471     paramDict 
= {'orient': ParamOrient}
 
 474 class xxxBoxSizer(xxxSizer
): 
 475     allParams 
= ['orient'] 
 476     required 
= ['orient'] 
 477     default 
= {'orient': 'wxVERTICAL'}
 
 478     # Tree icon depends on orientation 
 480         if self
.params
['orient'].value() == 'wxHORIZONTAL': return self
.imageH
 
 481         else: return self
.imageV
 
 483 class xxxStaticBoxSizer(xxxBoxSizer
): 
 484     allParams 
= ['label', 'orient'] 
 485     required 
= ['label', 'orient'] 
 486     default 
= {'orient': 'wxVERTICAL'}
 
 488 class xxxGridSizer(xxxSizer
): 
 489     allParams 
= ['cols', 'rows', 'vgap', 'hgap'] 
 491     default 
= {'cols': '2', 'rows': '2'}
 
 493 # For repeated parameters 
 496         self
.l
, self
.data 
= [], [] 
 497     def append(self
, param
): 
 499         self
.data
.append(param
.value()) 
 505         self
.l
, self
.data 
= [], [] 
 507 class xxxFlexGridSizer(xxxGridSizer
): 
 508     specials 
= ['growablecols', 'growablerows'] 
 509     allParams 
= ['cols', 'rows', 'vgap', 'hgap'] + specials
 
 510     paramDict 
= {'growablecols':ParamIntList, 'growablerows':ParamIntList}
 
 511     # Special processing for growable* parameters 
 512     # (they are represented by several nodes) 
 513     def special(self
, tag
, node
): 
 514         if tag 
not in self
.params
: 
 515             self
.params
[tag
] = xxxParamMulti() 
 516         self
.params
[tag
].append(xxxParamInt(node
)) 
 517     def setSpecial(self
, param
, value
): 
 518         # Straightforward implementation: remove, add again 
 519         self
.params
[param
].remove() 
 520         del self
.params
[param
] 
 522             node 
= tree
.dom
.createElement(param
) 
 523             text 
= tree
.dom
.createTextNode(str(i
)) 
 524             node
.appendChild(text
) 
 525             self
.element
.appendChild(node
) 
 526             self
.special(param
, node
) 
 528 # Container with only one child. 
 530 class xxxChildContainer(xxxObject
): 
 531     hasName 
= hasStyle 
= false
 
 533     def __init__(self
, parent
, element
): 
 534         xxxObject
.__init
__(self
, parent
, element
) 
 535         # Must have one child with 'object' tag, but we don't check it 
 536         nodes 
= element
.childNodes
[:]   # create copy 
 538             if node
.nodeType 
== minidom
.Node
.ELEMENT_NODE
: 
 539                 if node
.tagName 
== 'object': 
 540                     # Create new xxx object for child node 
 541                     self
.child 
= MakeXXXFromDOM(self
, node
) 
 542                     self
.child
.parent 
= parent
 
 543                     # Copy hasChildren and isSizer attributes 
 544                     self
.hasChildren 
= self
.child
.hasChildren
 
 545                     self
.isSizer 
= self
.child
.isSizer
 
 548                 element
.removeChild(node
) 
 550         assert 0, 'no child found' 
 552 class xxxSizerItem(xxxChildContainer
): 
 553     allParams 
= ['option', 'flag', 'border'] 
 554     paramDict 
= {'option': ParamInt}
 
 555     def __init__(self
, parent
, element
): 
 556         xxxChildContainer
.__init
__(self
, parent
, element
) 
 557         # Remove pos parameter - not needed for sizeritems 
 558         if 'pos' in self
.child
.allParams
: 
 559             self
.child
.allParams 
= self
.child
.allParams
[:] 
 560             self
.child
.allParams
.remove('pos') 
 562 class xxxNotebookPage(xxxChildContainer
): 
 563     allParams 
= ['label', 'selected'] 
 564     paramDict 
= {'selected': ParamBool}
 
 566     def __init__(self
, parent
, element
): 
 567         xxxChildContainer
.__init
__(self
, parent
, element
) 
 568         # pos and size dont matter for notebookpages 
 569         if 'pos' in self
.child
.allParams
: 
 570             self
.child
.allParams 
= self
.child
.allParams
[:] 
 571             self
.child
.allParams
.remove('pos') 
 572         if 'size' in self
.child
.allParams
: 
 573             self
.child
.allParams 
= self
.child
.allParams
[:] 
 574             self
.child
.allParams
.remove('size') 
 576 class xxxSpacer(xxxObject
): 
 577     hasName 
= hasStyle 
= false
 
 578     allParams 
= ['size', 'option', 'flag', 'border'] 
 579     paramDict 
= {'option': ParamInt}
 
 580     default 
= {'size': '0,0'}
 
 582 class xxxMenuBar(xxxContainer
): 
 585 class xxxMenu(xxxContainer
): 
 586     allParams 
= ['label'] 
 587     default 
= {'label': ''}
 
 588     paramDict 
= {'style': ParamNonGenericStyle}    
# no generic styles 
 589     winStyles 
= ['wxMENU_TEAROFF'] 
 591 class xxxMenuItem(xxxObject
): 
 592     allParams 
= ['checkable', 'label', 'accel', 'help'] 
 593     default 
= {'label': ''}
 
 595 class xxxSeparator(xxxObject
): 
 596     hasName 
= hasStyle 
= false
 
 598 ################################################################################ 
 602     'wxDialog': xxxDialog
, 
 605     'wxToolBar': xxxToolBar
, 
 607     'wxBitmap': xxxBitmap
, 
 610     'wxButton': xxxButton
, 
 611     'wxBitmapButton': xxxBitmapButton
, 
 612     'wxRadioButton': xxxRadioButton
, 
 613     'wxSpinButton': xxxSpinButton
, 
 615     'wxStaticBox': xxxStaticBox
, 
 616     'wxStaticBitmap': xxxStaticBitmap
, 
 617     'wxRadioBox': xxxRadioBox
, 
 618     'wxComboBox': xxxComboBox
, 
 619     'wxCheckBox': xxxCheckBox
, 
 620     'wxListBox': xxxListBox
, 
 622     'wxStaticText': xxxStaticText
, 
 623     'wxStaticLine': xxxStaticLine
, 
 624     'wxTextCtrl': xxxTextCtrl
, 
 625     'wxChoice': xxxChoice
, 
 626     'wxSlider': xxxSlider
, 
 628     'wxScrollBar': xxxScrollBar
, 
 629     'wxTreeCtrl': xxxTreeCtrl
, 
 630     'wxListCtrl': xxxListCtrl
, 
 631     'wxCheckList': xxxCheckList
, 
 632     'wxNotebook': xxxNotebook
, 
 633     'notebookpage': xxxNotebookPage
, 
 634     'wxHtmlWindow': xxxHtmlWindow
, 
 635     'wxCalendar': xxxCalendar
, 
 637     'wxBoxSizer': xxxBoxSizer
, 
 638     'wxStaticBoxSizer': xxxStaticBoxSizer
, 
 639     'wxGridSizer': xxxGridSizer
, 
 640     'wxFlexGridSizer': xxxFlexGridSizer
, 
 641     'sizeritem': xxxSizerItem
, 
 644     'wxMenuBar': xxxMenuBar
, 
 646     'wxMenuItem': xxxMenuItem
, 
 647     'separator': xxxSeparator
, 
 650 # Create IDs for all parameters of all classes 
 651 paramIDs 
= {'fg': wxNewId(), 'bg': wxNewId(), 'exstyle': wxNewId(), 'font': wxNewId(), 
 652             'enabled': wxNewId(), 'focused': wxNewId(), 'hidden': wxNewId(), 
 655 for cl 
in xxxDict
.values(): 
 657         for param 
in cl
.allParams 
+ cl
.paramDict
.keys(): 
 658             if not paramIDs
.has_key(param
): 
 659                 paramIDs
[param
] = wxNewId() 
 661 ################################################################################ 
 664 # Test for object elements 
 666     return node
.nodeType 
== minidom
.Node
.ELEMENT_NODE 
and node
.tagName 
== 'object' 
 668 # Make XXX object from some DOM object, selecting correct class 
 669 def MakeXXXFromDOM(parent
, element
): 
 671         return xxxDict
[element
.getAttribute('class')](parent
, element
) 
 673         # Verify that it's not recursive exception 
 674         if element
.getAttribute('class') not in xxxDict
: 
 675             print 'ERROR: unknown class:', element
.getAttribute('class') 
 678 # Make empty DOM element 
 679 def MakeEmptyDOM(className
):  
 680     elem 
= tree
.dom
.createElement('object') 
 681     elem
.setAttribute('class', className
) 
 682     # Set required and default parameters 
 683     xxxClass 
= xxxDict
[className
] 
 684     defaultNotRequired 
= filter(lambda x
, l
=xxxClass
.required
: x 
not in l
, 
 685                                 xxxClass
.default
.keys()) 
 686     for param 
in xxxClass
.required 
+ defaultNotRequired
: 
 687         textElem 
= tree
.dom
.createElement(param
) 
 689             textNode 
= tree
.dom
.createTextNode(xxxClass
.default
[param
]) 
 691             textNode 
= tree
.dom
.createTextNode('') 
 692         textElem
.appendChild(textNode
) 
 693         elem
.appendChild(textElem
) 
 696 # Make empty XXX object 
 697 def MakeEmptyXXX(parent
, className
): 
 698     # Make corresponding DOM object first 
 699     elem 
= MakeEmptyDOM(className
) 
 700     # If parent is a sizer, we should create sizeritem object, except for spacers 
 702         if parent
.isSizer 
and className 
!= 'spacer': 
 703             sizerItemElem 
= MakeEmptyDOM('sizeritem') 
 704             sizerItemElem
.appendChild(elem
) 
 706         elif isinstance(parent
, xxxNotebook
): 
 707             pageElem 
= MakeEmptyDOM('notebookpage') 
 708             pageElem
.appendChild(elem
) 
 710     # Now just make object 
 711     return MakeXXXFromDOM(parent
, elem
)