本文整理汇总了Python中pyjamas.ui.HorizontalPanel.HorizontalPanel.getWidgetIndex方法的典型用法代码示例。如果您正苦于以下问题:Python HorizontalPanel.getWidgetIndex方法的具体用法?Python HorizontalPanel.getWidgetIndex怎么用?Python HorizontalPanel.getWidgetIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.HorizontalPanel.HorizontalPanel
的用法示例。
在下文中一共展示了HorizontalPanel.getWidgetIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TabBar
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import getWidgetIndex [as 别名]
class TabBar(Composite):
STYLENAME_DEFAULT = "gwt-TabBarItem"
def __init__(self, **kwargs):
if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-TabBar"
# this is awkward: HorizontalPanel is the composite,
# so we either the element here, and pass it in to HorizontalPanel.
element = None
if kwargs.has_key('Element'):
element = kwargs.pop('Element')
self.panel = HorizontalPanel(Element=element)
self.selectedTab = None
self.tabListeners = []
self.panel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM)
first = HTML(" ", True)
rest = HTML(" ", True)
first.setStyleName("gwt-TabBarFirst")
rest.setStyleName("gwt-TabBarRest")
first.setHeight("100%")
rest.setHeight("100%")
self.panel.add(first)
self.panel.add(rest)
first.setHeight("100%")
self.panel.setCellHeight(first, "100%")
self.panel.setCellWidth(rest, "100%")
Composite.__init__(self, self.panel, **kwargs)
self.sinkEvents(Event.ONCLICK)
def addTab(self, text, asHTML=False):
self.insertTab(text, asHTML, self.getTabCount())
def addTabListener(self, listener):
self.tabListeners.append(listener)
def getSelectedTab(self):
if self.selectedTab is None:
return -1
return self.panel.getWidgetIndex(self.selectedTab) - 1
def getTabCount(self):
return self.panel.getWidgetCount() - 2
def getTabHTML(self, index):
if index >= self.getTabCount():
return None
delPanel = self.panel.getWidget(index + 1)
focusablePanel = delPanel.getFocusablePanel()
widget = focusablePanel.getWidget()
if hasattr(widget, "getHTML"):
return widget.getHTML()
elif hasattr(widget, "getText"): # assume it's a Label if it has getText
return widget.getText()
else:
fpe = DOM.getParent(self.focusablePanel.getElement())
return DOM.getInnerHTML(fpe)
def createTabTextWrapper(self):
return None
def insertTab(self, text, asHTML, beforeIndex=None):
""" 1st arg can, instead of being 'text', be a widget.
1st arg can also be None, which results in a blank
space between tabs. Use this to push subsequent
tabs out to the right hand end of the TabBar.
(the "blank" tab, by not being focussable, is not
clickable).
"""
if beforeIndex is None:
beforeIndex = asHTML
asHTML = False
if (beforeIndex < 0) or (beforeIndex > self.getTabCount()):
#throw new IndexOutOfBoundsException();
pass
if text is None:
text = HTML(" ", True)
text.setWidth("100%")
text.setStyleName("gwt-TabBarRest")
self.panel.insert(text, beforeIndex + 1)
self.panel.setCellWidth(text, "100%")
return
istext = isinstance(text, basestring)
if istext:
if asHTML:
item = HTML(text)
else:
item = Label(text)
item.setWordWrap(False)
#.........这里部分代码省略.........