本文整理汇总了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)