本文整理汇总了Python中pyjamas.ui.VerticalPanel.VerticalPanel.getWidgetCount方法的典型用法代码示例。如果您正苦于以下问题:Python VerticalPanel.getWidgetCount方法的具体用法?Python VerticalPanel.getWidgetCount怎么用?Python VerticalPanel.getWidgetCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.VerticalPanel.VerticalPanel
的用法示例。
在下文中一共展示了VerticalPanel.getWidgetCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LoggerPanel
# 需要导入模块: from pyjamas.ui.VerticalPanel import VerticalPanel [as 别名]
# 或者: from pyjamas.ui.VerticalPanel.VerticalPanel import getWidgetCount [as 别名]
class LoggerPanel(DisclosurePanel):
def __init__(self, maxhistory=100, maxloglinelength=200, headerStyleName=None, panelStyleName=None,
buttonStyleName=None, labelStyleName=None):
super(LoggerPanel, self).__init__(self, header='BLAH', isOpen=False)
self.labelStyleName = labelStyleName
self.maxhistory = maxhistory
self.maxloglinelength = maxloglinelength
self.getHeader().setStyleName(headerStyleName)
self.logpanel = VerticalPanel(StyleName=panelStyleName)
self.setContent(self.logpanel)
self.clearbutton = Button('Clear', listener=self.clear, StyleName=buttonStyleName)
self.logpanel.add(self.clearbutton)
self.updateHeaderText()
def log(self, string):
self.logpanel.add(Label(string[:self.maxloglinelength], StyleName=self.labelStyleName))
widgcnt = self.logpanel.getWidgetCount()
if widgcnt > self.maxhistory:
for i in range(0, widgcnt - self.maxhistory):
self.logpanel.remove(self.logpanel.getWidget(i))
self.updateHeaderText()
def __call__(self, string):
self.log(string)
return
def updateHeaderText(self):
self.getHeader().setText('Logging: %s items' % (self.logpanel.getWidgetCount() - 1))
def clear(self):
self.logpanel.clear()
self.logpanel.add(self.clearbutton)
self.updateHeaderText()