def write(self, outfile, tabs, class_names=None): "Writes the xml code for the widget to the given output file" # XXX move this to the widget import edit_sizers fwrite = outfile.write assert self.widget is not None # write object tag, including class, name, base classname = getattr(self.widget, '_classname', self.widget.__class__.__name__) # to disable custom class code generation (for panels...) if getattr(self.widget, 'no_custom_class', False): no_custom = u' no_custom_class="1"' else: no_custom = "" outer_tabs = u' ' * tabs fwrite(u'%s<object %s %s %s%s>\n' % (outer_tabs, common.format_xml_attrs(**{'class': self.widget.klass}), common.format_xml_attrs(name=self.widget.name), common.format_xml_attrs(base=classname), no_custom)) # write properties, but without name and class # XXX be 100% compatible to 0.7.2, where option is written into the object; remove later properties = self.widget.get_properties( without=set(edit_sizers.SizerBase.MANAGED_PROPERTIES)) #properties = self.widget.get_properties(without=set(["pos","flag","border"])) for prop in properties: prop.write(outfile, tabs + 1) if class_names is not None and self.widget.__class__.__name__ != 'CustomWidget': class_names.add(self.widget.klass) if isinstance(self.widget, edit_sizers.SizerBase): for child in self.children or []: if not isinstance(child, SlotNode): # hasattr(child, 'widget'): inner_xml = compat.StringIO() for name in edit_sizers.SizerBase.MANAGED_PROPERTIES: name = child.widget.properties[name] if name is not None: name.write(inner_xml, tabs + 2) child.write(inner_xml, tabs + 2, class_names) stmt = common.format_xml_tag(u'object', inner_xml.getvalue(), tabs + 1, is_xml=True, **{'class': 'sizeritem'}) fwrite(stmt) else: child.write(outfile, tabs + 1) elif self.children is not None: for child in self.children: child.write(outfile, tabs + 1, class_names) fwrite(u'%s</object>\n' % outer_tabs)
def write(self, output, tabs): "Writes the xml code for the widget to the given output file" # write object tag, including class, name, base classname = self.get_editor_name() # to disable custom class code generation (for panels...) outer_tabs = u' ' * tabs instance_class = '' if "class" in self.properties: klass = self.get_prop_value("class", default=self.WX_CLASS) if self.check_prop_truth("instance_class"): instance_class = " " + common.format_xml_attrs( instance_class=self.instance_class) else: klass = self.get_prop_value("instance_class", default=self.WX_CLASS) output.append( u'%s<object %s %s %s%s>\n' % (outer_tabs, common.format_xml_attrs(**{'class': klass}), common.format_xml_attrs(name=self.name), common.format_xml_attrs(base=classname), instance_class)) if config.debugging and getattr(self, "_restore_properties", None): raise ValueError("properties not restored") self.restore_properties() # write properties, but without name and class # XXX be 100% compatible to 0.7.2, where option is written into the object; remove later properties = self.get_properties(without=set(MANAGED_PROPERTIES)) for prop in properties: prop.write(output, tabs + 1) if self.IS_SIZER: for child in self.children or []: if not child.IS_SLOT: inner_xml = [] for name in MANAGED_PROPERTIES: name = child.properties[name] if name is not None: name.write(inner_xml, tabs + 2) child.write(inner_xml, tabs + 2) stmt = common.format_xml_tag(u'object', inner_xml, tabs + 1, is_xml=True, **{'class': 'sizeritem'}) output.extend(stmt) else: child.write(output, tabs + 1) elif self.children is not None or self.ATT_CHILDREN is not None: for child in self.get_all_children(): assert not config.debugging or child is not None child.write(output, tabs + 1) output.append(u'%s</object>\n' % outer_tabs)
def write(self, output, tabs): "Writes the xml code for the widget to the given output file" # write object tag, including class, name, base #classname = getattr(self, '_classname', self.__class__.__name__) #if classname=="EditToplevelMenuBar": classname = "EditMenuBar" classname = self.get_editor_name() # to disable custom class code generation (for panels...) if getattr(self, 'no_custom_class', False): no_custom = u' no_custom_class="1"' else: no_custom = "" outer_tabs = u' ' * tabs output.append( u'%s<object %s %s %s%s>\n' % (outer_tabs, common.format_xml_attrs(**{'class': self.klass}), common.format_xml_attrs(name=self.name), common.format_xml_attrs(base=classname), no_custom)) if config.debugging and getattr(self, "_restore_properties", None): raise ValueError("properties not restored") self.restore_properties() # write properties, but without name and class # XXX be 100% compatible to 0.7.2, where option is written into the object; remove later properties = self.get_properties(without=set(MANAGED_PROPERTIES)) for prop in properties: prop.write(output, tabs + 1) if self.IS_SIZER: for child in self.children or []: if not child.IS_SLOT: inner_xml = [] for name in MANAGED_PROPERTIES: name = child.properties[name] if name is not None: name.write(inner_xml, tabs + 2) child.write(inner_xml, tabs + 2) stmt = common.format_xml_tag(u'object', inner_xml, tabs + 1, is_xml=True, **{'class': 'sizeritem'}) output.extend(stmt) else: child.write(output, tabs + 1) elif self.children is not None or self.ATT_CHILDREN is not None: for child in self.get_all_children(): assert not config.debugging or child is not None child.write(output, tabs + 1) output.append(u'%s</object>\n' % outer_tabs)