gui/component.py
def duplicate(self, new_parent=None):
        "Create a new object exactly similar to self"
        kwargs = {}
        for spec_name, spec in self._meta.specs.items():
            value = getattr(self, spec_name)
            if isinstance(value, Color):
                print "COLOR", value, value.default
                if value.default:
                    value = None
            if value is not None:
                kwargs[spec_name] = value
        del kwargs['parent'] 
        new_id = wx.NewId()
        kwargs['id'] = new_id
        kwargs['name'] = "%s_%s" % (kwargs['name'], new_id)
        new_obj = self.__class__(new_parent or self.get_parent(), **kwargs)
        # recursively create a copy of each child (in the new parent!)
        for child in self:
            child.duplicate(new_obj)
        return new_obj
def duplicate(self, new_parent=None):
        "Create a new object exactly similar to self"
        kwargs = {}
        for spec_name, spec in self._meta.specs.items():
            value = getattr(self, spec_name)
            if isinstance(value, Color):
                print "COLOR", value, value.default
                if value.default:
                    value = None
            if value is not None:
                kwargs[spec_name] = value
        del kwargs['parent'] 
        new_id = wx.NewId()
        kwargs['id'] = new_id
        kwargs['name'] = "%s_%s" % (kwargs['name'], new_id)
        new_obj = self.__class__(new_parent or self.get_parent(), **kwargs)
        # recursively create a copy of each child (in the new parent!)
        for child in self:
            child.duplicate(new_obj)
        return new_obj
Create a new object exactly similar to self