本文整理汇总了Python中pyjamas.DOM.getStyleAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.getStyleAttribute方法的具体用法?Python DOM.getStyleAttribute怎么用?Python DOM.getStyleAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.getStyleAttribute方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getStyleAttribute
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def getStyleAttribute(self, attribute):
""" can be called with two forms:
getStyleAttribute(self, attr) - returns value
getStyleAttribute(self, (attr1,attr2,...)) - returns dictionary of attr:value pairs
"""
if isinstance(attribute, basestring):
return DOM.getStyleAttribute(self.getElement(), attribute)
# if attribute is not a string, assume it is iterable,
# and return the multi-attribute form
el = self.getElement()
result = {}
for attr in attribute:
result[attr] = DOM.getStyleAttribute(el, attr)
return result
示例2: identify
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def identify(self, element):
if element.nodeType != 1:
return False
if str(string.lower(element.tagName)) != 'span':
return False
style = DOM.getStyleAttribute(element, "font-family")
return style is not None
示例3: setDragImage
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [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)
示例4: copyStyles
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def copyStyles(elem1, elem2):
"""
Copy styles from one element to another, like in
http://efreedom.com/Question/1-1848445/Duplicating-Element-Style-JavaScript
"""
element_style = getComputedStyle(elem1)
if element_style:
element_style = dict(element_style)
else:
return
for style in element_style:
try:
value = element_style[style]
if isinstance(value, str):
if not style == 'cssText':
DOM.setStyleAttribute(elem2, style, value)
if value == 'font':
DOM.setStyleAttribute(elem2, 'fontSize',
DOM.getStyleAttribute(elem1, 'fontSize'))
except:
pass
示例5: WidgetLocation
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
if info.initialDraggableParent instanceof AbsolutePanel:
info.initialDraggableParentLocation = WidgetLocation(widget,
info.initialDraggableParent)
elif info.initialDraggableParent instanceof HorizontalPanel:
info.initialDraggableIndex = ((HorizontalPanel) info.initialDraggableParent).getWidgetIndex(widget)
elif info.initialDraggableParent instanceof VerticalPanel:
info.initialDraggableIndex = ((VerticalPanel) info.initialDraggableParent).getWidgetIndex(widget)
elif info.initialDraggableParent instanceof FlowPanel:
info.initialDraggableIndex = ((FlowPanel) info.initialDraggableParent).getWidgetIndex(widget)
elif info.initialDraggableParent instanceof SimplePanel:
# save nothing
else:
raise RuntimeException(
"Unable to handle 'initialDraggableParent instanceof "
+ GWT.getTypeName(info.initialDraggableParent)
+ "'; Please create your own DragController and override saveDraggableLocationAndStyle() and restoreDraggableLocation()")
info.initialDraggableMargin = DOM.getStyleAttribute(widget.getElement(), "margin")
DOM.setStyleAttribute(widget.getElement(), "margin", "0px")
savedWidgetInfoMap.put(widget, info)
def getIntersectDropController(self, x, y):
DropController dropController = dropControllerCollection.getIntersectDropController(x, y)
return dropController is not None ? dropController : boundaryDropController
示例6: getStyleAttr
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def getStyleAttr(self, row, column, attr):
elem = self.getElement(row, column)
return DOM.getStyleAttribute(elem, attr)
示例7: getTextAlignment
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def getTextAlignment(self, align):
return DOM.getStyleAttribute(self.getElement(), "textAlign")
示例8: getWordWrap
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def getWordWrap(self):
ws = DOM.getStyleAttribute(self.getElement(), "whiteSpace")
return ws != "nowrap"
示例9: getCellVerticalAlignment
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def getCellVerticalAlignment(self, widget):
td = self.getWidgetTd(widget)
if td is None:
return None
return DOM.getStyleAttribute(td, "verticalAlign")
示例10: getWordWrap
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def getWordWrap(self):
return not (DOM.getStyleAttribute(self.getElement(), "whiteSpace") == "nowrap")
示例11: onMouseMove
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getStyleAttribute [as 别名]
def onMouseMove(self, sender, x, y):
event = DOM.eventGetCurrentEvent()
self.mouseEvent = event
button = DOM.eventGetButton(event)
if not button == Event.BUTTON_LEFT:
return
## The following commented code lets the native dnd happen in IE. sucks.
## But it may enable dragging our widgets out of IE into other apps.
# else:
# try:
# self.dragWidget.getElement().dragDrop()
# return
# except:
# pass
# Adjust x and y to absolute coordinates.
x, y = eventCoordinates(event)
if self.dragging == DRAGGING_NO_MOVEMENT_YET:
self.origMouseX = x
self.origMouseY = y
self.currentDragOperation = 'none'
fromElement = self.dragWidget.getElement()
# Is the widget itself draggable?
try:
draggable = fromElement.draggable
except:
draggable = False
# if not, find the draggable element at (x, y) in the widget
if not draggable:
fromElement = findDraggable(sender.getElement(),
self.origMouseX, self.origMouseY)
# Nothing draggable found. return.
if fromElement is None:
self.dragging = NOT_DRAGGING
return
# Get the location for the dragging widget
#self.absParent = None
#self.absParent = self.dragWidget.getParent()
#self.absLeft = DOM.getStyleAttribute(fromElement, 'left')
#print self.absLeft
#self.absTop = DOM.getStyleAttribute(fromElement, 'top')
#print self.absTop
#self.origTop = DOM.getAbsoluteTop(fromElement) + parent.getAbsoluteTop()
#self.origLeft = DOM.getAbsoluteLeft(fromElement) + parent.getAbsoluteLeft()
self.origTop = DOM.getAbsoluteTop(fromElement)
self.origLeft = DOM.getAbsoluteLeft(fromElement)
#self.glassTop = DOM.getAbsoluteTop(fromElement.offsetParent)
#self.glassLeft = DOM.getAbsoluteTop(fromElement.offsetParent)
position_absolute = DOM.getStyleAttribute(fromElement,
'position') == 'absolute'
if position_absolute:
self.dragLeftOffset = (self.origMouseX -
DOM.getAbsoluteLeft(fromElement.offsetParent))
self.dragTopOffset = (self.origMouseY -
DOM.getAbsoluteTop(fromElement.offsetParent))
else:
self.dragLeftOffset = self.origMouseX - self.origLeft
self.dragTopOffset = self.origMouseY - self.origTop
# self.setDragImage(fromElement,
# self.origMouseX - self.origLeft,
# self.origMouseY - self.origTop)
self.dragDataStore.elements = [fromElement]
dragStartEvent = self.fireDNDEvent('dragstart', None,
self.dragWidget)
if not isCanceled(dragStartEvent):
self.initFeedbackImage()
RootPanel().add(self.draggingImage)
self.setDragImageLocation(x, y)
self.dragging = ACTIVELY_DRAGGING
GlassWidget.show(self)
elif self.dragging == ACTIVELY_DRAGGING:
try:
doc().selection.empty()
except:
wnd().getSelection().removeAllRanges()
self.setDragImageLocation(x, y)
# If we are still working on the previous iteration, or if we have
# done this recently, we'll wait for the next event.
if self.dragBusy or time.time() - self.drag_time < 0.25:
return
self.doDrag(event, x, y)
self.drag_time = time.time()