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


Python DOM.getAbsoluteLeft方法代码示例

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


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

示例1: onElementContextmenu

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def onElementContextmenu(self, sender,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     s = self.desc[self.elements.index(sender)]
     self.set_status('Contextmenue on Element '+s+' at '+str(x)+', '+str(y))
     DOM.eventCancelBubble(event,True)
     DOM.eventPreventDefault(event)
开发者ID:brodybits,项目名称:pyjs,代码行数:9,代码来源:events.py

示例2: fireMouseEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
def fireMouseEvent(listeners, sender, event):
    x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(sender.getElement())
    y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(sender.getElement())

    etype = DOM.eventGetType(event)
    if etype == "mousedown":
        for listener in listeners:
            listener.onMouseDown(sender, x, y)
        return True
    elif etype == "mouseup":
        for listener in listeners:
            listener.onMouseUp(sender, x, y)
        return True
    elif etype == "mousemove":
        for listener in listeners:
            listener.onMouseMove(sender, x, y)
        return True
    elif etype == "mouseover":
        from_element = DOM.eventGetFromElement(event)
        if not DOM.isOrHasChild(sender.getElement(), from_element):
            for listener in listeners:
                listener.onMouseEnter(sender)
        return True
    elif etype == "mouseout":
        to_element = DOM.eventGetToElement(event)
        if not DOM.isOrHasChild(sender.getElement(), to_element):
            for listener in listeners:
                listener.onMouseLeave(sender)
        return True
    return False
开发者ID:anandology,项目名称:pyjamas,代码行数:32,代码来源:MouseListener.py

示例3: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def __init__(self):
     """ Standard initialiser.
     """
     VerticalPanel.__init__(self)
     self.canvas = Raphael(900,700)
     self.add(self.canvas)
     x = DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.getAbsoluteTop(self.canvas.getElement())
     self.offset = (x,y)
开发者ID:labase,项目名称:jeppeto,代码行数:11,代码来源:pyjamas_driver.py

示例4: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def onBrowserEvent(self, event):
    kind = DOM.eventGetType(event)
    x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.getElement())
    y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.getElement())
    y = HEIGHT - y
    if kind == "mousedown":
       self.onMouseDown(x,y)
       self._dragging = True
    elif kind == "mousemove" and self._dragging:
       self.onMouseDrag(x,y)
    elif (kind == "mouseup" or kind == "mouseout") and self._dragging:
       self._dragging = False
       self.onMouseUp(x,y)
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:15,代码来源:PyjSketchGUI.py

示例5: isIn

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
def isIn(element, x, y):
    """
    Given an element and an absolute x and y, return True if the
    (x,y) coordinate is within the element. Otherwise, return False.
    """
    top = DOM.getAbsoluteTop(element)
    height = DOM.getIntAttribute(element, 'offsetHeight')
    if y >= top and y <= top + height:
        left = DOM.getAbsoluteLeft(element)
        width = DOM.getIntAttribute(element, 'offsetWidth')
        if x >= left and x <= left + width:
            return True
    return False
开发者ID:anandology,项目名称:pyjamas,代码行数:15,代码来源:utils.py

示例6: onBrowserEvent

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def onBrowserEvent(self, event):
    print "Event happened"
    kind = DOM.eventGetType(event)
    x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
    y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
    print "Type of event: %s" % (kind)
    if kind == "mousedown":
       self._dragging = True
       self.onMouseDown(x,y)
    elif kind == "mousemove" and self._dragging:
       self.onMouseDrag(x,y)
    elif (kind == "mouseup" or kind == "mouseout") and self._dragging:
       self._dragging = False
       self.onMouseUp(x,y)
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:16,代码来源:tester.py

示例7: onDragStart

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     clientX = event.clientX
     clientY = event.clientY
     absx = clientX + Window.getScrollLeft()
     absy = clientY + Window.getScrollTop()
     package = json.encode({"text": DOM.getInnerText(target),
                            "offsetX": absx - DOM.getAbsoluteLeft(target),
                            "offsetY": absy - DOM.getAbsoluteTop(target)})
     dt.setData('text', package)
     # using "copy" here because Windows Chrome does not like "move"
     dt.allowedEffects = 'copy'
     self.movingWidget = None
     for widget in self.children:
         if target == widget.getElement():
             self.movingWidget = widget
开发者ID:anandology,项目名称:pyjamas,代码行数:19,代码来源:DNDTest.py

示例8: setDragImage

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def setDragImage(self, element, x, y):
     position_absolute = DOM.getStyleAttribute(element,
                                 'position') == 'absolute'
     if position_absolute:
         self.dragLeftOffset = x + DOM.getAbsoluteLeft(
                 element.offsetParent)
         self.dragTopOffset = y + DOM.getAbsoluteTop(
                 element.offsetParent)
     else:
         self.dragLeftOffset = x
         self.dragTopOffset = y
     if element.tagName.lower().endswith('img'):
         src = DOM.getAttribute(element,'src')
         element = DOM.createElement('img')
         DOM.setAttribute(element, 'src', src)
     if not self.draggingImage:
         self.createDraggingImage(element)
     else:
         self.draggingImage.setImage(element)
开发者ID:Afey,项目名称:pyjs,代码行数:21,代码来源:DNDHelper.py

示例9: moveFocus

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
    def moveFocus(self, selection):
        focusableWidget = selection.getFocusableWidget()
        if focusableWidget is not None:
            focusableWidget.setFocus(True)
            DOM.scrollIntoView(focusableWidget.getElement())
        else:
            selectedElem = selection.getContentElem()
            containerLeft = self.getAbsoluteLeft()
            containerTop = self.getAbsoluteTop()

            left = DOM.getAbsoluteLeft(selectedElem) - containerLeft
            top = DOM.getAbsoluteTop(selectedElem) - containerTop
            width = DOM.getIntAttribute(selectedElem, "offsetWidth")
            height = DOM.getIntAttribute(selectedElem, "offsetHeight")

            DOM.setIntStyleAttribute(self.focusable, "left", left)
            DOM.setIntStyleAttribute(self.focusable, "top", top)
            DOM.setIntStyleAttribute(self.focusable, "width", width)
            DOM.setIntStyleAttribute(self.focusable, "height", height)

            DOM.scrollIntoView(self.focusable)
            Focus.focus(self.focusable)
开发者ID:anandology,项目名称:pyjamas,代码行数:24,代码来源:Tree.py

示例10: onClick

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def onClick(self, sender, evt):
     x = DOM.eventGetClientX(evt)-DOM.getAbsoluteLeft(self.getElement())
     y = DOM.eventGetClientY(evt)-DOM.getAbsoluteTop(self.getElement())
     xth = int(x/uwidth)
     yth = int(y/uheight)
     box = self.map[yth][xth]
     if not box:
         return
     box.toggleSelect()
     if not box.selected:
         self.selected_box = None
     elif self.selected_box==None:
         self.selected_box = box
     elif box.img != self.selected_box.img:
         # change selection
         self.selected_box.unSelect()
         self.selected_box = box
     else:
         sbox = self.selected_box
         print 'check'
         result = False
         if box.xth<sbox.xth:
             print (box.yth,box.xth), (sbox.yth,sbox.xth)
             result = checkllk(self.map, (box.yth,box.xth), (sbox.yth,sbox.xth))
         else:
             print (sbox.yth,sbox.xth), (box.yth,box.xth)
             result = checkllk(self.map, (sbox.yth,sbox.xth), (box.yth,box.xth))
         if result:
             print 'path:', result
             sbox.dead()
             self.map[sbox.yth][sbox.xth] = 0
             box.dead()
             self.map[box.yth][box.xth] = 0
             self.selected_box = None
         else:
             print 'fail'
             self.selected_box.unSelect()
             self.selected_box = box
开发者ID:yihuang,项目名称:huangyilib,代码行数:40,代码来源:LlkApp.py

示例11: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def __init__(self):
     """ Standard initialiser.
     """
     VerticalPanel.__init__(self)
     GUI_Event.__init__(self)
     self.canvas = Raphael(900,700)
     #self.canvas.addListener('mousedown',self.test)
     #self.canvas.addListener('contextmenu',self.test)
     #self.tb = TextArea()
     #self.tb.setName("textBoxFormElement")
     #self.tb.setStyleAttribute({'position':'absolute',
     #    'top':'175px','left':'158px'
     #    ,'color':COLOR['maroon']
     #    ,'background':COLOR['peachpuff']
     #    ,'background-color':COLOR['peachpuff']})
     #self.tb.setSize(450,100)
     #self.tb.setReadonly('readonly')
     self.add(self.canvas)
     #self.add(self.tb)
     x = DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.getAbsoluteTop(self.canvas.getElement())
     self.offset = (x,y)
     '''
开发者ID:labase,项目名称:jeppeto,代码行数:25,代码来源:pyjamas_factory.py

示例12: onCanvasMouseup

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def onCanvasMouseup(self,obj,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     self.set_status('Mousemove on Canvas at '+str(x)+', '+str(y))
开发者ID:brodybits,项目名称:pyjs,代码行数:6,代码来源:events.py

示例13: new_mouse_pos

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def new_mouse_pos(self, x, y):
     el = self.canvas.getElement()
     self.mouse_pos_x = x - DOM.getAbsoluteLeft(el)
     self.mouse_pos_y = y - DOM.getAbsoluteTop(el)
开发者ID:davelab6,项目名称:telaro,代码行数:6,代码来源:dash2.py

示例14: onElementDblClick

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def onElementDblClick(self,sender,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     s = self.desc[self.elements.index(sender)]
     self.set_status('Doubleclick on Element '+s+' at '+str(x)+', '+str(y))
     DOM.eventCancelBubble(event,True)
开发者ID:brodybits,项目名称:pyjs,代码行数:8,代码来源:events.py

示例15: onCanvasContextmenu

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteLeft [as 别名]
 def onCanvasContextmenu(self, sender,event):
     x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(self.canvas.getElement())
     y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(self.canvas.getElement())
     self.set_status('Contextmenue on Canvas at '+str(x)+', '+str(y))
     DOM.eventPreventDefault(event)
开发者ID:brodybits,项目名称:pyjs,代码行数:7,代码来源:events.py


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