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


Python Grid.getAbsoluteTop方法代码示例

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


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

示例1: InputBox

# 需要导入模块: from pyjamas.ui.Grid import Grid [as 别名]
# 或者: from pyjamas.ui.Grid.Grid import getAbsoluteTop [as 别名]
class InputBox(FocusPanel):

    _props = [ ("maxLength", "Max Length", "MaxLength", int),
               ("text", "Text", "Text", None),
               ("matchPattern", "Match Pattern", "MatchPattern", None),
               ("cursorStyle", "Cursor Style", "CursorStyle", None),
             ]

    @classmethod
    def _getProps(self):
        return FocusPanel._getProps() + self._props

    def __init__(self, **kwargs):
        """ setMatchPattern - defaults to '' to match everything
            match pattern examples: '^[0-9]*$' is for digits only
                                    '^[0-9,A-Z]*$' is for digits and uppercase
            setMaxLength
            setText
OB        """

        kwargs['MatchPattern'] = kwargs.pop('MatchPattern', '')
        cs = kwargs.pop('CursorStyle', "inputbox-cursor")
        gs = kwargs.pop('StyleName', 'gwt-inputbox')

        ap = AbsolutePanel(StyleName="inputbox")
        self.tp = Grid(StyleName=gs, Width="100%", Height="100%",
                       CellPadding=0, CellSpacing=0)
        self.cursor = HTML(StyleName=cs)
        ap.add(self.tp)
        ap.add(self.cursor, 0, 0)
        self.cf = self.tp.getCellFormatter()

        FocusPanel.__init__(self, Widget=ap, **kwargs)

        self.addTableListener(self)
        self.addKeyboardListener(self)
        self.addFocusListener(self)

        self.word_selected_pos = 0
        self.ctimer = Timer(notify=self.cursorFlash)
        self.focusset = False
        self.cstate = False
        self._keypressListeners = []
  
    def addKeypressListener(self, listener):
        self._keypressListeners.append(listener)

    def removeKeypressListener(self, listener):
        self._keypressListeners.remove(listener)

    def getMatchPattern(self):
        return self.mp

    def setMatchPattern(self, mp):
        self.mp = mp
        self.rexp = re.compile(self.mp)

    def addDblTableListener(self, listener):
        self.tp.addDblTableListener(listener)

    def addTableListener(self, listener):
        self.tp.addTableListener(listener)

    def _move_cursor(self, col):
        """ moves the css-styled cursor
        """
        #old style (useful for insert mode - don't delete this line for now!)
        #self.cf.setStyleName(0, col, "inputbox-square-word-cursor", highlight)

        el = self.cf.getRawElement(0, col+1)
        w = self.getWidget()
        px = self.tp.getAbsoluteLeft()
        py = self.tp.getAbsoluteTop()
        width = DOM.getOffsetWidth(el)
        px = DOM.getAbsoluteLeft(el) -  px
        py = DOM.getAbsoluteTop(el) - py 
        w.setWidgetPosition(self.cursor, px, py)

    def _highlight_cursor(self, col, highlight):
        """ highlights (or dehighlights) the currently selected cell
        """
        #old style (useful for insert mode - don't delete this line for now!)
        #self.cf.setStyleName(0, col, "inputbox-square-word-cursor", highlight)

        print "_highlight", col, highlight
        self._move_cursor(col)
        self.cursor.setStyleName("inputbox-square-word-cursor", highlight)

    def set_grid_value(self, v, y, x):

        if v:
            w = ""
        else:
            w = "0px"
        v = v or EMPTY
        s = HTML(v, StyleName="inputbox-square")
        self.tp.setWidget(y, x, s)
        self.cf.setAlignment(y, x,  HasAlignment.ALIGN_LEFT,
                                    HasAlignment.ALIGN_MIDDLE)
        self.cf.setWidth(y, x,  w)
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


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