当前位置: 首页>>代码示例>>Python>>正文


Python Group.replace_include方法代码示例

本文整理汇总了Python中group.Group.replace_include方法的典型用法代码示例。如果您正苦于以下问题:Python Group.replace_include方法的具体用法?Python Group.replace_include怎么用?Python Group.replace_include使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在group.Group的用法示例。


在下文中一共展示了Group.replace_include方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: View

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import replace_include [as 别名]
class View ( ViewElement ):
    
    #---------------------------------------------------------------------------
    #  Trait definitions:
    #---------------------------------------------------------------------------

    id        = id_trait        # The name of the view
    content   = content_trait   # The top-level Group object for the view
    menubar   = Any             # The menu bar for the view
    toolbar   = Any             # The menu bar for the view
#   menubar   = menubar_trait   # The menu bar for the view
#   toolbar   = toolbar_trait   # The tool bar for the view
    handler   = handler_trait   # The Handler object for handling events
    title     = title_trait     # The modal/wizard dialog window title
    kind      = kind_trait      # The kind of user interface to create
    object    = object_trait    # The default object being edited
    style     = style_trait     # The style of user interface to create
    on_apply  = on_apply_trait  # Called when modal changes are applied/reverted
    apply     = apply_trait     # Should an Apply button be added?
    revert    = revert_trait    # Should a Revert button be added?
    undo      = undo_trait      # Should Undo/Redo buttons be added?
    ok        = ok_trait        # Should OK/Cancel buttons be added?
    resizable = resizable_trait # Should dialog be resizable?
    help      = help_trait      # Should a Help button be added?
    help_id   = help_id_trait   # External help context identifier
    x         = x_trait         # Requested view window x coordinate
    y         = y_trait         # Requested view window y coordinate
    width     = width_trait     # Requested view window width
    height    = height_trait    # Requested view window height
    
    # Note: Group objects delegate their 'object' and 'style' traits to the View
    
    #---------------------------------------------------------------------------
    #  Initializes the object:
    #---------------------------------------------------------------------------

    def __init__ ( self, *values, **traits ):
        """ Initializes the object.
        """
        ViewElement.__init__( self, **traits )
        content = []
        accum   = []
        for value in values:
            if isinstance( value, Group ):
                self._flush( content, accum )
                content.append( value )
            elif type( value ) in SequenceTypes:
                self._flush( content, accum )
                content.append( Group( *value ) )
            else:
                accum.append( value )
        self._flush( content, accum )
        
        # If 'content' trait was specified, add it to the end of the content:
        if self.content is not None:
            content.append( self.content )
        
        # Make sure this View is the container for all its children:
        for item in content:
            item.container = self
            
        # Wrap all of the content up into a Group and save it as our content:
        self.content = Group( container = self, *content )

    #---------------------------------------------------------------------------
    #  Creates a UI user interface object:
    #---------------------------------------------------------------------------
    
    def ui ( self, context, parent        = None, 
                            kind          = None, 
                            view_elements = None, 
                            handler       = None ):
        """ Creates a UI user interface object.
        """
        if type( context ) is not dict:
            context = { 'object': context }
        ui = UI( view          = self,
                 context       = context,
                 handler       = handler or self.handler or default_handler(),
                 view_elements = view_elements )
        if kind is None:
            kind = self.kind
        ui.ui( parent, kind )
        return ui
    
    #---------------------------------------------------------------------------
    #  Replaces any items which have an 'id' with an Include object with the 
    #  same 'id', and puts the object with the 'id' into the specified 
    #  ViewElements object: 
    #---------------------------------------------------------------------------
    
    def replace_include ( self, view_elements ):
        """ Replaces any items which have an 'id' with an Include object with 
            the same 'id', and puts the object with the 'id' into the specified 
            ViewElements object.
        """
        if self.content is not None:
            self.content.replace_include( view_elements )

    #---------------------------------------------------------------------------
#.........这里部分代码省略.........
开发者ID:pv,项目名称:matplotlib-cvs,代码行数:103,代码来源:view.py

示例2: View

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import replace_include [as 别名]

#.........这里部分代码省略.........
        # Group:
        for item in content:
            if isinstance(item, Item):
                content = [Group(*content)]
                break

        # Wrap all of the content up into a Group and save it as our content:
        self.content = Group(container=self, *content)

    def ui(self, context, parent=None, kind=None, view_elements=None, handler=None, id="", scrollable=None, args=None):
        """ Creates a **UI** object, which generates the actual GUI window or
            panel from a set of view elements.

            Parameters
            ----------
            context : object or dictionary
                A single object or a dictionary of string/object pairs, whose
                facet attributes are to be edited. If not specified, the current
                object is used.
            parent : window component
                The window parent of the View object's window
            kind : string
                The kind of window to create. See the **AKind** facet for
                details. If *kind* is unspecified or None, the **kind**
                attribute of the View object is used.
            view_elements : ViewElements object
                The set of Group, Item, and Include objects contained in the
                view. Do not use this parameter when calling this method
                directly.
            handler : Handler object
                A handler object used for event handling in the dialog box. If
                None, the default handler for Facets UI is used.
            id : string
                A unique ID for persisting preferences about this user
                interface, such as size and position. If not specified, no user
                preferences are saved.
            scrollable : Boolean
                Indicates whether the dialog box should be scrollable. When set
                to True, scroll bars appear on the dialog box if it is not large
                enough to display all of the items in the view at one time.

        """
        handler = handler or self.handler or default_handler()
        if not isinstance(handler, Handler):
            handler = handler()

        if args is not None:
            handler.set(**args)

        if not isinstance(context, dict):
            context = context.facet_context()

        context.setdefault("handler", handler)
        handler = context["handler"]

        if self.model_view is not None:
            context["object"] = self.model_view(context["object"])

        self_id = self.id
        if self_id != "":
            if id != "":
                id = "%s:%s" % (self_id, id)
            else:
                id = self_id

        if scrollable is None:
            scrollable = self.scrollable

        if kind is None:
            kind = self.kind

        ui = UI(
            view=self,
            context=context,
            handler=handler,
            view_elements=view_elements,
            title=self.title,
            id=id,
            kind=kind,
            scrollable=scrollable,
        )

        ui.ui(parent)

        return ui

    def replace_include(self, view_elements):
        """ Replaces any items that have an ID with an Include object with
            the same ID, and puts the object with the ID into the specified
            ViewElements object.
        """
        if self.content is not None:
            self.content.replace_include(view_elements)

    def __repr__(self):
        """ Returns a "pretty print" version of the View.
        """
        return self._repr_format(
            self.content.content, "title", "id", "kind", "resizable", "scrollable", "x", "y", "width", "height"
        )
开发者ID:davidmorrill,项目名称:facets,代码行数:104,代码来源:view.py

示例3: View

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import replace_include [as 别名]

#.........这里部分代码省略.........
    
    def ui ( self, context, parent        = None, kind       = None, 
                            view_elements = None, handler    = None,
                            id            = '',   scrollable = None,
                            args          = None ):
        """ Creates a **UI** object, which generates the actual GUI window or
        panel from a set of view elements.
        
        Parameters
        ----------
        context : object or dictionary
            A single object or a dictionary of string/object pairs, whose trait
            attributes are to be edited. If not specified, the current object is
            used.
        parent : window component 
            The window parent of the View object's window
        kind : string
            The kind of window to create. See the **kind_trait** trait for 
            details. If *kind* is unspecified or None, the **kind** attribute
            of the View object is used.
        view_elements : ViewElements object 
            The set of Group, Item, and Include objects contained in the view.
            Do not use this parameter when calling this method directly.
        handler : Handler object
            A handler object used for event handling in the dialog box. If
            None, the default handler for Traits UI is used.
        id : string
            A unique ID for persisting preferences about this user interface,
            such as size and position. If not specified, no user preferences
            are saved.
        scrollable : Boolean
            Indicates whether the dialog box should be scrollable. When set to 
            True, scroll bars appear on the dialog box if it is not large enough
            to display all of the items in the view at one time.
        
        """
        handler = handler or self.handler or default_handler()
        if not isinstance( handler, Handler ):
            handler = handler()
        if args is not None:
            handler.set( **args )
        
        if not isinstance( context, dict ):
            context = context.trait_context()
            
        context.setdefault( 'handler', handler )
                        
        if self.model_view is not None:
            context[ 'object' ] = self.model_view( context[ 'object' ] )
            
        self_id = self.id
        if self_id != '':
            if id != '':
                id = '%s:%s' % ( self_id, id )
            else:
                id = self_id
                
        if scrollable is None:
            scrollable = self.scrollable
            
        ui = UI( view          = self,
                 context       = context,
                 handler       = handler,
                 view_elements = view_elements,
                 title         = self.title,
                 id            = id,
                 scrollable    = scrollable )
                 
        if kind is None:
            kind = self.kind
        
        ui.ui( parent, kind )
        
        return ui
    
    #---------------------------------------------------------------------------
    #  Replaces any items which have an 'id' with an Include object with the 
    #  same 'id', and puts the object with the 'id' into the specified 
    #  ViewElements object: 
    #---------------------------------------------------------------------------
    
    def replace_include ( self, view_elements ):
        """ Replaces any items that have an ID with an Include object with 
            the same ID, and puts the object with the ID into the specified 
            ViewElements object.
        """
        if self.content is not None:
            self.content.replace_include( view_elements )
        
    #---------------------------------------------------------------------------
    #  Returns a 'pretty print' version of the View:
    #---------------------------------------------------------------------------
            
    def __repr__ ( self ):
        """ Returns a "pretty print" version of the View.
        """
        if self.content is None:
            return '()'
        return "( %s )" %  ', '.join( 
               [ item.__repr__() for item in self.content.content ] )
开发者ID:gkliska,项目名称:razvoj,代码行数:104,代码来源:view.py


注:本文中的group.Group.replace_include方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。