recycleview.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:KivyTrek 作者: peterLaurence 项目源码 文件源码
def create_view(self, index, viewclass=None):
        """Creates and initializes the view for the data at `index`. The
        returned view is synced with the data, except for the pos/size
        properties.
        """
        if viewclass is None:
            viewclass = self.get_viewclass(index)
        if viewclass is None:
            return
        item = self[index]
        # FIXME: we could pass the data though the constructor, but that wont
        # work for kv-declared classes, and might lead the user to think it can
        # work for reloading as well.
        view = viewclass()
        if viewclass not in _view_base_cache:
            _view_base_cache[viewclass] = isinstance(view, RecycleViewMixin)

        if _view_base_cache[viewclass]:
            view.refresh_view_attrs(self.recycleview, item)
        else:
            for key, value in item.items():
                setattr(view, key, value)
        return view
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号