当前位置: 首页>>代码示例>>Python>>正文


Python ScrollPanel.getWidget方法代码示例

本文整理汇总了Python中pyjamas.ui.ScrollPanel.ScrollPanel.getWidget方法的典型用法代码示例。如果您正苦于以下问题:Python ScrollPanel.getWidget方法的具体用法?Python ScrollPanel.getWidget怎么用?Python ScrollPanel.getWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.ui.ScrollPanel.ScrollPanel的用法示例。


在下文中一共展示了ScrollPanel.getWidget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HorizontalCollapsePanel

# 需要导入模块: from pyjamas.ui.ScrollPanel import ScrollPanel [as 别名]
# 或者: from pyjamas.ui.ScrollPanel.ScrollPanel import getWidget [as 别名]
class HorizontalCollapsePanel(FlowPanel):
    def __init__(self, *args, **kwargs):
        # set defaults
        if not 'StyleName' in kwargs:
            kwargs['StyleName'] = "rjw-HorizontalCollapsePanel"

        FlowPanel.__init__(self, *args, **kwargs)

        self._containers = [
                ScrollPanel(StyleName = self.getStylePrimaryName() + '-left'),
                ScrollPanel(StyleName = self.getStylePrimaryName() + '-right'),
        ]
        self._collapse_widget = ScrollPanel(StyleName = self.getStylePrimaryName() + '-collapse')
        collapse_button = ToggleButton(StyleName = self.getStylePrimaryName() + '-collapse-button')
        collapse_button.addClickListener(self._sync_collapse)
        self._collapse_widget.add(collapse_button)

        FlowPanel.add(self, self._containers[0])
        FlowPanel.add(self, self._collapse_widget)
        FlowPanel.add(self, self._containers[1])

        self._sync_collapse()

    def _sync_collapse(self, w=None):
        collapse_button = self._collapse_widget.getWidget(0)
        if collapse_button.isDown():
            self.addStyleName(self.getStylePrimaryName() + '-collapsed')
        else:
            self.removeStyleName(self.getStylePrimaryName() + '-collapsed')

    def getWidget(self, index):
        if index >= 0 and index < len(self._containers):
            return self._containers[index].getWidget()
        console.error('HorizontalCollapsePanel.getWidget passed invalid index: ' + str(index))
        raise IndexError('Index out of range')

    def setWidget(self, index, widget):
        if index >= 0 and index < len(self._containers):
            return self._containers[index].setWidget(widget)
        console.error('HorizontalCollapsePanel.setWidget passed invalid index: ' + str(index))
        raise IndexError('Index out of range')

    # Adds a widget to a pane
    def add(self, widget):
        if self.getWidget(0) == None:
            self.setWidget(0, widget)
        elif self.getWidget(1) == None:
            self.setWidget(1, widget)
        else:
            console.error("HorizontalCollapsePanel can only contain two child widgets.")

    # Removes a child widget.
    def remove(self, widget):
        if self.getWidget(0) == widget:
            self._containers[0].remove(widget)
        elif self.getWidget(1) == widget:
            self._containers[1].remove(widget)
        else:
            AbsolutePanel.remove(self, widget)
开发者ID:rjw57,项目名称:foldbeam,代码行数:61,代码来源:HorizontalCollapsePanel.py

示例2: SplitPanel

# 需要导入模块: from pyjamas.ui.ScrollPanel import ScrollPanel [as 别名]
# 或者: from pyjamas.ui.ScrollPanel.ScrollPanel import getWidget [as 别名]

#.........这里部分代码省略.........
        if self._isDragging():
            # stop dragging on mouse up
            self._stopDragging()

    # called when we start dragging
    def onMouseGlassEnter(self, sender):
        pass

    # called when we drag out of the window
    # (NOT called when we just stop dragging)
    def onMouseGlassLeave(self, sender):
        # we left the window, so stop dragging
        self._stopDragging()

    #
    # Start the inherited 'public' API
    #

    # specify splitter position in pix OR percentage
    # if pixels (number) specified, we can make change now
    # otherwise, we have to set the offset as specified, then
    # 'fixup' the remaining space after rendering
    def setSplitPosition(self, pos=None):
        if pos is not None:
            # remember last pos set
            self._pos = pos
        else:
            pos = self._pos
        if pos < 1:
            pos = 1
            self._pos = pos
        # change adjustable dimension
        if self._vertical:
            self._container1.setHeight(pos)
        else:
            self._container1.setWidth(pos)
        # if pix are given, we can try to finalize the positions
        finalized = False
        if isinstance(pos, int):
            finalized = self._finalizePositions(pos)
        # if needed, queue callback to finalize
        if not finalized:
            DeferredCommand.add(self._finalizePositions)

    def getWidget(self, index):
        if index == 0:
            return self._container1.getWidget()
        return self._container2.getWidget()

    def setWidget(self, index, widget):
        if index == 0:
            return self._container1.setWidget(widget)
        return self._container2.setWidget(widget)

    # Adds a widget to a pane
    def add(self, widget):
        if self.getWidget(0) == None:
            self.setWidget(0, widget)
        elif self.getWidget(1) == None:
            self.setWidget(1, widget)
        else:
            console.error("SimplePanel can only contain one child widget")

    # Removes a child widget.
    def remove(self, widget):
        if self.getWidget(0) == widget:
            self._container1.remove(widget)
        elif self.getWidget(1) == widget:
            self._container2.remove(widget)
        else:
            AbsolutePanel.remove(self, widget)

    # Gets the content element for the given index.
    def getElement(self, index=None):
        if index is None:
            return AbsolutePanel.getElement(self)
        return self.getWidget(index).getElement()

    # Gets the widget in the pane at end of the line direction for the layout
    def getEndOfLineWidget(self):
        return self.getWidget(1)

    # Gets the element that is acting as the splitter.
    def getSplitElement(self):
        return self._splitter.getElement()

    # Gets the widget in the pane at the start of line direction for the layout
    def getStartOfLineWidget(self):
        return self.getWidget(0)

    # Indicates whether the split panel is being resized.
    def isResizing(self):
        return False

    # Sets the widget in the pane at the end of line direction for the layout
    def setEndOfLineWidget(self, widget):
        self.setWidget(1, widget)

    def setStartOfLineWidget(self, widget):
        self.setWidget(0, widget)
开发者ID:,项目名称:,代码行数:104,代码来源:


注:本文中的pyjamas.ui.ScrollPanel.ScrollPanel.getWidget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。