本文整理汇总了Python中pyjamas.ui.HorizontalPanel.HorizontalPanel.insert方法的典型用法代码示例。如果您正苦于以下问题:Python HorizontalPanel.insert方法的具体用法?Python HorizontalPanel.insert怎么用?Python HorizontalPanel.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.HorizontalPanel.HorizontalPanel
的用法示例。
在下文中一共展示了HorizontalPanel.insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TabBar
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import insert [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)
#.........这里部分代码省略.........
示例2: onModuleLoad
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import insert [as 别名]
class InfoDirectory:
def onModuleLoad(self):
self.remote = InfoServicePython()
self.tree_width = 200
self.tp = HorizontalPanel()
self.tp.setWidth("%dpx" % (self.tree_width))
self.treeview = Trees()
self.treeview.fTree.addTreeListener(self)
self.sp = ScrollPanel()
self.tp.add(self.treeview)
self.sp.add(self.tp)
self.sp.setHeight("100%")
self.horzpanel1 = HorizontalPanel()
self.horzpanel1.setSize("100%", "100%")
self.horzpanel1.setBorderWidth(1)
self.horzpanel1.setSpacing("10px")
self.rp = RightPanel()
self.rps = ScrollPanel()
self.rps.add(self.rp)
self.rps.setWidth("100%")
self.rp.setWidth("100%")
self.cp1 = CollapserPanel(self)
self.cp1.setWidget(self.sp)
self.cp1.setHTML(" ")
self.midpanel = MidPanel(self)
self.cp2 = CollapserPanel(self)
self.cp2.setWidget(self.midpanel)
self.cp2.setHTML(" ")
self.horzpanel1.add(self.cp1)
self.horzpanel1.add(self.cp2)
self.horzpanel1.add(self.rps)
self.cp1.setInitialWidth("%dpx" % self.tree_width)
self.cp2.setInitialWidth("200px")
RootPanel().add(self.horzpanel1)
width = Window.getClientWidth()
height = Window.getClientHeight()
self.onWindowResized(width, height)
Window.addWindowResizeListener(self)
def setCollapserWidth(self, widget, width):
self.horzpanel1.setCellWidth(widget, width)
def onWindowResized(self, width, height):
#self.hp.setWidth("%dpx" % (width - self.tree_width))
#self.hp.setHeight("%dpx" % (height - 20))
self.cp1.setHeight("%dpx" % (height - 30))
self.cp2.setHeight("%dpx" % (height - 30))
self.rps.setHeight("%dpx" % (height - 30))
self.horzpanel1.setHeight("%dpx" % (height - 20))
def onTreeItemStateChanged(self, item):
if item.isSelected():
self.onTreeItemSelected(item)
def onTreeItemSelected(self, item):
obj = item.getUserObject()
if len(obj.children) != 0:
self.clear_mid_panel()
return
self.remote.get_midpanel_data(obj.root + "/" + obj.text, self)
self.cp2.setHTML(obj.text)
self.clear_right_panel()
def clear_right_panel(self):
self.horzpanel1.remove(2)
self.horzpanel1.insert(HTML(""), 2)
self.rp.setTitle(" ")
def clear_mid_panel(self):
self.clear_right_panel()
#self.horzpanel2.setLeftWidget(HTML(""))
def set_mid_panel(self, response):
self.midpanel.set_items(response)
self.cp2.setWidget(self.midpanel)
def select_right_grid(self, location, name):
self.horzpanel1.remove(2)
self.horzpanel1.insert(self.rps, 2)
self.rp.setTitle(name)
self.remote.get_rightpanel_datanames(location, self)
#.........这里部分代码省略.........