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


Python DOM.getOffsetWidth方法代码示例

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


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

示例1: _setSplitPositionUsingPixels

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getOffsetWidth [as 别名]
    def _setSplitPositionUsingPixels(self, px):
        """ Set the splitter's position in units of pixels.
              
              px represents the splitter's position as a distance
              of px pixels from the left edge of the container. This is
              true even in a bidi environment. Callers of this method
              must be aware of this constraint.
        """
        splitElem = self.panel.getSplitElement()

        rootElemWidth = DOM.getOffsetWidth(self.panel.container)
        splitElemWidth = DOM.getOffsetWidth(splitElem)

        # This represents an invalid state where layout is incomplete. This
        # typically happens before DOM attachment, but I leave it here as a
        # precaution because negative width/height style attributes produce
        # errors on IE.
        if (rootElemWidth < splitElemWidth):
            return

        # Compute the new right side width.
        newRightWidth = rootElemWidth - px - splitElemWidth

        # Constrain the dragging to the physical size of the panel.
        if (px < 0):
            px = 0
            newRightWidth = rootElemWidth - splitElemWidth
        elif (newRightWidth < 0):
            px = rootElemWidth - splitElemWidth
            newRightWidth = 0

        rightElem = self.panel.getWidgetElement(1)

        # Set the width of the left side.
        self.panel.setElemWidth(self.panel.getWidgetElement(0), "%dpx" % px)

        # Move the splitter to the right edge of the left element.
        self.panel.setLeft(splitElem, "%dpx" % px)

        # Move the right element to the right of the splitter.
        self.panel.setLeft(rightElem, "%dpx" % (px + splitElemWidth))

        self.updateRightWidth(rightElem, newRightWidth)
开发者ID:certik,项目名称:pyjamas,代码行数:45,代码来源:horizsplitpanel.py

示例2: setSplitPosition

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getOffsetWidth [as 别名]
 def setSplitPosition(self, pos):
     leftElem = self.panel.getWidgetElement(0)
     self.panel.setElemWidth(leftElem, pos)
     self.setSplitPositionUsingPixels(DOM.getOffsetWidth(leftElem))
开发者ID:certik,项目名称:pyjamas,代码行数:6,代码来源:horizsplitpanel.py

示例3: onSplitterResizeStarted

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getOffsetWidth [as 别名]
 def onSplitterResizeStarted(self, x, y):
     self.initialThumbPos = x
     self.initialLeftWidth = DOM.getOffsetWidth(self.getWidgetElement(0))
开发者ID:certik,项目名称:pyjamas,代码行数:5,代码来源:horizsplitpanel.py


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