本文整理汇总了Python中pyjamas.DOM.getAbsoluteTop方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.getAbsoluteTop方法的具体用法?Python DOM.getAbsoluteTop怎么用?Python DOM.getAbsoluteTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.getAbsoluteTop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onElementContextmenu
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)
示例2: fireMouseEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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
示例3: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)
示例4: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)
示例5: isIn
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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
示例6: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)
示例7: onDragStart
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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
示例8: moveSlider
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [as 别名]
def moveSlider(self, mouse_y):
relative_y = mouse_y - DOM.getAbsoluteTop(self.getElement())
widget_height = self.getOffsetHeight()
# limit the position to be in the widget!
if relative_y < 0:
relative_y = 0
height_range = widget_height - 10 # handle height is hard-coded
if relative_y >= height_range:
relative_y = height_range
# move the handle
DOM.setStyleAttribute(self.handle, "top", "%dpx" % relative_y)
DOM.setStyleAttribute(self.handle, "position", "absolute")
val_diff = self.max_value - self.min_value
new_value = ((val_diff * relative_y) / height_range) + self.min_value
self.setValue(new_value)
示例9: setDragImage
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)
示例10: moveFocus
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)
示例11: onClick
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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
示例12: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)
'''
示例13: onClick
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [as 别名]
def onClick(self, sender, event):
# work out the relative position of cursor
mouse_y = DOM.eventGetClientY(event) - \
DOM.getAbsoluteTop(sender.getElement())
self.moveSlider(mouse_y)
示例14: onElementDblClick
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)
示例15: onCanvasContextmenu
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAbsoluteTop [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)