本文整理汇总了Python中pyjamas.DOM.appendChild方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.appendChild方法的具体用法?Python DOM.appendChild怎么用?Python DOM.appendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.appendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __init__(self, width=0, height=0):
Widget.__init__(self)
self.context = None
self.setElement(DOM.createDiv())
canvas = DOM.createElement("canvas")
self.setWidth(width)
self.setHeight(height)
canvas.width=width
canvas.height=height
DOM.appendChild(self.getElement(), canvas)
self.setStyleName("gwt-Canvas")
self.init()
self.context.fillStyle = "black"
self.context.strokeStyle = "black"
self.focusable = None
self.focusable = Focus.createFocusable()
self.focusListeners = []
self.clickListeners = []
self.mouseListeners = []
self.keyboardListeners = []
DOM.appendChild(self.getElement(), self.focusable)
DOM.sinkEvents(canvas, Event.ONCLICK | Event.MOUSEEVENTS | DOM.getEventsSunk(canvas))
DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS | Event.KEYEVENTS)
示例2: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __init__(self, **kwargs):
if not kwargs.has_key('CellFormatter'):
kwargs['CellFormatter'] = CellFormatter(self)
if not kwargs.has_key('RowFormatter'):
kwargs['RowFormatter'] = RowFormatter(self)
self.tableListeners = []
self.dbltableListeners = []
self.widgetMap = {}
if kwargs.has_key('Element'):
self.tableElem = kwargs.pop('Element')
fc = DOM.getFirstChild(self.tableElem)
if fc:
self.bodyElem = fc
else:
self.bodyElem = DOM.createTBody()
DOM.appendChild(self.tableElem, self.bodyElem)
else:
self.tableElem = DOM.createTable()
self.bodyElem = DOM.createTBody()
DOM.appendChild(self.tableElem, self.bodyElem)
self.setElement(self.tableElem)
self.sinkEvents(Event.ONCLICK | Event.ONDBLCLICK)
Panel.__init__(self, **kwargs)
示例3: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __init__(self, **kwargs):
self.body = None
self.visibleStack = -1
self.indices = {}
if kwargs.has_key('Element'):
table = kwargs.pop('Element')
fc = DOM.getFirstChild(table)
if fc:
self.body = fc
else:
self.body = DOM.createTBody()
DOM.appendChild(table, self.body)
else:
table = DOM.createTable()
self.body = DOM.createTBody()
DOM.appendChild(table, self.body)
self.setElement(table)
if not kwargs.has_key('Spacing'): kwargs['Spacing'] = 0
if not kwargs.has_key('Padding'): kwargs['Padding'] = 0
if not kwargs.has_key('StyleName'): kwargs['StyleName'] = "gwt-StackPanel"
DOM.sinkEvents(table, Event.ONCLICK)
ComplexPanel.__init__(self, **kwargs)
示例4: insert
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def insert(self, widget, container, beforeIndex=None):
""" has two modes of operation:
widget, beforeIndex
widget, container, beforeIndex.
if beforeIndex argument is not given, the 1st mode is assumed.
this technique is less costly than using *args.
"""
if widget.getParent() == self:
return
if beforeIndex is None:
beforeIndex = container
container = self.getBody()
widget.removeFromParent()
tr = DOM.createTR()
td = DOM.createTD()
DOM.insertChild(container, tr, beforeIndex)
DOM.appendChild(tr, td)
CellPanel.insert(self, widget, td, beforeIndex)
self.setCellHorizontalAlignment(widget, self.horzAlign)
self.setCellVerticalAlignment(widget, self.vertAlign)
示例5: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __init__(self, text, disclosurePanel):
Widget.__init__(self)
self.disclosurePanel = disclosurePanel
self.imageBase = pygwt.getModuleBaseURL()
self.root = DOM.createTable()
self.tbody = DOM.createTBody()
self.tr = DOM.createTR()
self.imageTD = DOM.createTD()
self.labelTD = DOM.createTD()
self.imgElem = DOM.createImg()
self.updateState()
self.setElement(self.root)
DOM.appendChild(self.root, self.tbody)
DOM.appendChild(self.tbody, self.tr)
DOM.appendChild(self.tr, self.imageTD)
DOM.appendChild(self.tr, self.labelTD)
DOM.appendChild(self.imageTD, self.imgElem)
self.setText(text)
disclosurePanel.addEventHandler(self)
self.updateState()
示例6: _checkVerticalContainer
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def _checkVerticalContainer(self):
""" use this to delay effect of self.vertical being set.
self.setVertical can now be used, rather than self.vertical
force-set in constructor
"""
if DOM.getChildCount(self.body) == 0:
DOM.appendChild(self.body, DOM.createTR())
示例7: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __init__(self, **ka):
ka['StyleName'] = ka.get('StyleName', "gwt-Tree")
self.root = None
self.childWidgets = Set()
self.curSelection = None
self.focusable = None
self.focusListeners = []
self.mouseListeners = []
self.imageBase = pygwt.getModuleBaseURL()
self.keyboardListeners = []
self.listeners = []
self.lastEventType = ""
element = ka.pop('Element', None) or DOM.createDiv()
self.setElement(element)
DOM.setStyleAttribute(self.getElement(), "position", "relative")
self.focusable = Focus.createFocusable()
# Hide focus outline in Mozilla/Webkit/Opera
DOM.setStyleAttribute(self.focusable, "outline", "0px")
# Hide focus outline in IE 6/7
DOM.setElemAttribute(self.focusable, "hideFocus", "true");
DOM.setStyleAttribute(self.focusable, "fontSize", "0")
DOM.setStyleAttribute(self.focusable, "position", "absolute")
DOM.setIntStyleAttribute(self.focusable, "zIndex", -1)
DOM.appendChild(self.getElement(), self.focusable)
self.root = RootTreeItem()
self.root.setTree(self)
Widget.__init__(self, **ka)
self.sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS)
DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS)
示例8: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __init__(self, min_value, max_value,
start_value=None, step=None,
**kwargs):
if not kwargs.has_key("StyleName"):
kwargs['StyleName'] = "gwt-VerticalSlider"
if kwargs.has_key('Element'):
# XXX FIXME: Focus.createFocusable is here for a reason...
element = kwargs.pop('Element')
else:
element = Focus.createFocusable()
DOM.setStyleAttribute(element, "position", "relative")
DOM.setStyleAttribute(element, "overflow", "hidden")
self.handle = DOM.createDiv()
DOM.appendChild(element, self.handle)
self.setHandleStyle("1px", "100%", "10px", "#808080")
# must use DoubleControl; otherwise, this init is = Vertical init,
# plus a change in the handle style
# this should be refactored, so that the AreaSlider
# can be built on VerticalSlider
DoubleControl.__init__(self, element, min_value, max_value,
start_value, step,
**kwargs)
self.addClickListener(self)
self.addFocusListener(self)
self.addMouseListener(self)
#Redefine VDS's styles for handle
self.setHandleStyle("1px", "10px", "10px", "#808080")
示例9: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __init__(self, min_value, max_value, start_value=None, step=None,
**kwargs):
if not kwargs.has_key("StyleName"): kwargs['StyleName'] = "gwt-VerticalSlider"
if kwargs.has_key('Element'):
# XXX FIXME: Focus.createFocusable is here for a reason...
element = kwargs.pop('Element')
else:
element = Focus.createFocusable()
DOM.setStyleAttribute(element, "position", "relative")
DOM.setStyleAttribute(element, "overflow", "hidden")
self.handle = DOM.createDiv()
DOM.appendChild(element, self.handle)
DOM.setStyleAttribute(self.handle, "border", "1px")
DOM.setStyleAttribute(self.handle, "width", "100%")
DOM.setStyleAttribute(self.handle, "height", "10px")
DOM.setStyleAttribute(self.handle, "backgroundColor", "#808080")
Control.__init__(self, element, min_value, max_value, start_value, step,
**kwargs)
self.addClickListener(self)
self.addFocusListener(self)
self.addMouseListener(self)
示例10: setWidget
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def setWidget(self, index, w):
""" Sets one of the contained widgets.
@param index the index, only 0 and 1 are valid
@param w the widget
"""
oldWidget = self.widgets[index]
if oldWidget == w:
return
if w is not None:
w.removeFromParent()
# Remove the old child.
if oldWidget is not None:
# Orphan old.
self.disown(oldWidget)
# Physical detach old.
#DOM.removeChild(self.elements[index], oldWidget.getElement())
# Logical detach old / attach new.
self.widgets[index] = w
if w is not None:
# Physical attach new.
DOM.appendChild(self.elements[index], w.getElement())
# Adopt new.
self.adopt(w, None)
示例11: setCurrentFaceElement
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def setCurrentFaceElement(self, newFaceElement):
# XXX: TODO
if self.curFaceElement != newFaceElement:
if self.curFaceElement is not None:
DOM.removeChild(self.getElement(), self.curFaceElement)
self.curFaceElement = newFaceElement
DOM.appendChild(self.getElement(), self.curFaceElement)
示例12: __init__
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __init__(self, img, **kwargs):
self.mouseListeners = []
if not kwargs.has_key('StyleName'):
kwargs['StyleName'] = 'gwt-HyperlinkImage'
Hyperlink.__init__(self, **kwargs)
DOM.appendChild(DOM.getFirstChild(self.getElement()), img.getElement())
img.unsinkEvents(Event.ONCLICK | Event.MOUSEEVENTS)
self.sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS)
示例13: __addLogElement
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def __addLogElement(self):
"""Add a container in the DOM where logging output will be written to.
This cannot be done in the constructor as it must happen late enough
to ensure a document body (to add an element to) does already exist."""
if self.div == None:
self.div = DOM.createDiv()
self.div.setAttribute('id', self.div_id)
DOM.appendChild(doc().body, self.div)
示例14: adopt
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def adopt(self, widget, container):
if container is not None:
widget.removeFromParent()
if indexBefore:
DOM.insertChild(container, widget.getElement(), indexBefore)
else:
DOM.appendChild(container, widget.getElement())
widget.setParent(self)
示例15: testDivHTML
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import appendChild [as 别名]
def testDivHTML(self):
e = DOM.getElementById('tests')
div = DOM.createElement('div')
DOM.appendChild(e, div)
DOM.setInnerHTML(div, 'hello world\n')
self.write_test_output('addDiv')
DOM.removeChild(e, div)
self.write_test_output('removeDiv')