Пример #1
0
    def __init__(self, *values, **traits):
        """ Initializes the object.
        """
        ViewSubElement.__init__(self, **traits)

        # Initialize the contents of the Group (if not done by parent):
        content = self.content
        if content is Undefined:
            self.content = content = []

        # Process all of the data passed to the constructor:
        for value in values:
            if isinstance(value, ViewSubElement):
                # Standard element type:
                content.append(value)
            elif type(value) in SequenceTypes:
                # Map (...) or [...] to a Group():
                content.append(Group(*value))
            elif type(value) is str:
                if value[0:1] in '-|':
                    # Parse Group trait options if specified as a string:
                    self._parse(value)
                elif (value[:1] == '<') and (value[-1:] == '>'):
                    # Convert string to an Include value:
                    content.append(Include(value[1:-1].strip()))
                else:
                    # Else let the Item class try to make sense of it:
                    content.append(Item(value))
            else:
                raise TypeError, "Unrecognized argument type: %s" % value

        # Make sure this Group is the container for all its children:
        for item in content:
            item.container = self
Пример #2
0
 def __init__ ( self, *values, **traits ):
     """ Initializes the object.
     """
     ViewSubElement.__init__( self, **traits )
     
     # Initialize the contents of the Group (if not done by parent):
     content = self.content
     if content is Undefined:
         self.content = content = []
         
     # Process all of the data passed to the constructor:
     for value in values:
         if isinstance( value, ViewSubElement ): 
             # Standard element type:
             content.append( value )
         elif type( value ) in SequenceTypes:
             # Map (...) or [...] to a Group():
             content.append( Group( *value ) )
         elif type( value ) is str:
             if value[0:1] in '-|':
                 # Parse Group trait options if specified as a string:
                 self._parse( value )
             elif (value[:1] == '<') and (value[-1:] == '>'):
                 # Convert string to an Include value:
                 content.append( Include( value[1:-1].strip() ) )
             else:
                 # Else let the Item class try to make sense of it:
                 content.append( Item( value ) )
         else:
             raise TypeError, "Unrecognized argument type: %s" % value
             
     # Make sure this Group is the container for all its children:
     for item in content:
         item.container = self
Пример #3
0
 def __init__ ( self, value = None, **traits ):
     ViewSubElement.__init__( self, **traits )
     if value is None:
         return
     if not type( value ) is str:
         raise TypeError, ("The argument to Item must be a string of the "
                       "form: {id:}{object.}{name}{[label]}{$|@|*|~|;style}")
     value = self._parse_label( value )
     value = self._parse_style( value )
     value = self._option( value, '#', 'resizable', True )
     value = self._split( 'id',     value, ':', find,  0, 1 )
     value = self._split( 'object', value, '.', find,  0, 1 )
     if value != '':
         self.name = value