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


Python VerticalPanel.getChildren方法代码示例

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


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

示例1: ContentPanel

# 需要导入模块: from pyjamas.ui.VerticalPanel import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel.VerticalPanel import getChildren [as 别名]
class ContentPanel(HorizontalPanel):
    def __init__(self, onItemPublish, onItemLike, onItemDislike, onSort=None, onFilter=None):
        super(ContentPanel, self).__init__()
        self.newItemArgs = {'onPublish':onItemPublish, 'onLike':onItemLike, 'onDislike':onItemDislike}

        self.sidebar = SideVerticalToolbar(onSort=onSort, onFilter=onFilter)
        text = '<br>'.join(list('More Tools'))
        self.sidebarEdge = Button(text, listener=self.onSidebarEdgeClick, StyleName=Styles.TOOLBAR_VERTICALEDGE)
        self.add(self.sidebarEdge)

        self.contentpanel = VerticalPanel()
        self.add(self.contentpanel)
        self.allContentCells = []
        return
    def _getAllContentItemCells(self):
        for widg in self.contentpanel.getChildren():
            if isinstance(widg, ContentItemCell):
                yield widg
    def addItems(self, items):
        for item in items:
            widg = ContentItemCell(item, **self.newItemArgs)
            self.contentpanel.add(widg)
            self.allContentCells.append(widg)
    def itemCount(self):
        return len(self.allContentCells)
    def onSidebarEdgeClick(self):
        #If parent is set, hide it- otherwise, remove it
        if self.sidebar.parent:
            self.sidebar.removeFromParent()
        else:
            self.insert(self.sidebar, 0)
    def setItemsOpenState(self, state):
        for cell in self._getAllContentItemCells():
            cell.setOpen(state)
    def sortItems(self, keyselector, ascending):
        allchildren = list(self.contentpanel.getChildren())
        self.contentpanel.clear()
        sall = sorted(allchildren, key=keyselector)
        if not ascending:
            sall = reversed(sall)
        for child in sall:
            self.contentpanel.add(child)
    def filterItems(self, predicate):
        self.contentpanel.clear()
        cellsToShow = [cell for cell in self.allContentCells if predicate(cell)]
        for cell in cellsToShow:
            self.contentpanel.add(cell)
开发者ID:satyam07,项目名称:taoggregator,代码行数:49,代码来源:feedpublisherwebui.py


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