本文整理汇总了Python中pyjamas.ui.ScrollPanel.ScrollPanel.setWidget方法的典型用法代码示例。如果您正苦于以下问题:Python ScrollPanel.setWidget方法的具体用法?Python ScrollPanel.setWidget怎么用?Python ScrollPanel.setWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ScrollPanel.ScrollPanel
的用法示例。
在下文中一共展示了ScrollPanel.setWidget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SplitPanel
# 需要导入模块: from pyjamas.ui.ScrollPanel import ScrollPanel [as 别名]
# 或者: from pyjamas.ui.ScrollPanel.ScrollPanel import setWidget [as 别名]
class SplitPanel(AbsolutePanel, MouseHandler, EventGenerator):
""" Provides the SplitPanel baseclass functionality
A SplitPanel is an AbsolutePanel containing an HTMLTable
with three cells. The first cell holds the first ScrollPanel,
while the center cell holds a Splitter, and the last cell
holds the other ScrollPanel.
"""
def __init__(self, vertical=False, **kwargs):
# set defaults
if not 'StyleName' in kwargs:
if vertical: # vertical split panel
kwargs['StyleName'] = "gwt-VerticalSplitPanel"
else:
kwargs['StyleName'] = "gwt-HorizontalSplitPanel"
# splitter drag state vars
self._drag_start = None
self._pos = "50%"
# orientation
self._vertical = vertical
# now init the bases
AbsolutePanel.__init__(self, **kwargs)
MouseHandler.__init__(self)
# add our event support?
self.addListenedEvent("Resize")
# create the top/left widget container
self._container1 = ScrollPanel()
# create the bottom/right widget container
self._container2 = ScrollPanel()
# create the splitter
self._splitter = SplitPanelSplitter(self)
# add splitter handling
self._splitter.addMouseListener(self)
# add mouse event handling
self.addMouseListener(self)
# add the parts
AbsolutePanel.add(self, self._container1, 0, 0)
AbsolutePanel.add(self, self._splitter, 0, 0)
AbsolutePanel.add(self, self._container2, 0, 0)
# set the layout
if vertical: # vertical split panel
self._splitter.setStyleName("vsplitter")
self._splitter.setWidth("100%")
self._container1.setWidth("100%")
self._container2.setWidth("100%")
# set drag cursor
DOM.setStyleAttribute(self._splitter.getElement(),
"cursor", "n-resize")
else: # horizontal split panel
self._splitter.setStyleName("hsplitter")
self._splitter.setHeight("100%")
self._container1.setHeight("100%")
self._container2.setHeight("100%")
# set drag cursor
DOM.setStyleAttribute(self._splitter.getElement(),
"cursor", "e-resize")
def onAttach(self):
AbsolutePanel.onAttach(self)
self.setSplitPosition()
# fixup the container 2 size and position
def _finalizePositions(self, pos=None):
finalized = False
if self._vertical:
if pos is None:
pos = self._container1.getOffsetHeight()
space = self.getOffsetHeight()
sz = self._splitter.getOffsetHeight()
if space > 0 and sz > 0 and pos > 0:
# limit pos
if pos > space - sz:
pos = space - sz
self._container1.setHeight(pos)
self.setWidgetPosition(self._splitter, 0, pos)
self.setWidgetPosition(self._container2, 0, pos + sz)
self._container2.setHeight(space - (pos + sz))
finalized = True
else:
if pos is None:
pos = self._container1.getOffsetWidth()
space = self.getOffsetWidth()
sz = self._splitter.getOffsetWidth()
if space > 0 and sz > 0 and pos > 0:
# limit pos
if pos > space - sz:
pos = space - sz
self._container1.setWidth(pos)
self.setWidgetPosition(self._splitter, pos, 0)
self.setWidgetPosition(self._container2, pos + sz, 0)
self._container2.setWidth(space - (pos + sz))
finalized = True
if finalized:
self.dispatchResizeEvent(self, pos)
return finalized
# end a drag operation
def _stopDragging(self):
if self._drag_start is not None:
#.........这里部分代码省略.........