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


Python DOM类代码示例

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


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

示例1: setWidget

    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 != None):
          w.removeFromParent()

        # Remove the old child.
        if (oldWidget != None):
          # Orphan old.
          orphan(oldWidget)
          # Physical detach old.
          DOM.removeChild(self.elements[index], oldWidget.getElement())

        # Logical detach old / attach new.
        self.widgets[index] = w

        if (w != None):
            # Physical attach new.
            DOM.appendChild(self.elements[index], w.getElement())

            # Adopt new.
            self.adopt(w)
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:29,代码来源:splitpanel.py

示例2: open

def open(self, bstrMethod, bstrUrl, varAsync = True, varUser = None, varPassword = None):
    DOM.dom_logging(log, "XMLHTTPRequest.open", bstrUrl)
    msg = "[Microsoft XMLHTTP ActiveX] open('%s', '%s', %s" % (bstrMethod, bstrUrl, varAsync is True, )
    if varUser:
        msg = "%s, '%s'" % (msg, varUser, )
    if varPassword:
        msg = "%s, '%s'" % (msg, varPassword, )
    msg = "%s)" % (msg, )
    log.ThugLogging.add_behavior_warn(msg)
    log.ThugLogging.log_exploit_event(self._window.url,
                                      "Microsoft XMLHTTP ActiveX",
                                      "Open",
                                      forward = False,
                                      data = {
                                                "method" : bstrMethod,
                                                "url"    : str(bstrUrl),
                                                "async"  : str(varAsync)
                                             }
                                     )
    
    self.bstrMethod  = bstrMethod
    self.bstrUrl     = str(bstrUrl)
    self.varAsync    = varAsync
    self.varUser     = varUser
    self.varPassword = varPassword
    return 0
开发者ID:execgit,项目名称:thugdom,代码行数:26,代码来源:MicrosoftXMLHTTP.py

示例3: replaceElement

 def replaceElement(self, element, widget):
     """
     Replace an existing element with the given widget
     """
     DOM.getParent(element).replaceChild(widget.getElement(), element)
     self.adopt(widget, None)
     self.children.append(widget)
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:7,代码来源:TemplatePanel.py

示例4: set_main_frame

def set_main_frame(frame):
    global main_frame
    main_frame = frame
    import DOM
    # ok - now the main frame has been set we can initialise the
    # signal handlers etc.
    DOM.init()
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:7,代码来源:__pyjamas__.py

示例5: getCellElement

 def getCellElement(self, row, cell) :
   """   Get a specific Element from the panel.
    
     @param row the row index
     @param cell the cell index
     @return the Element at the given row and cell
   """
   tr = DOM.getChild(self.tbody, row)
   td = DOM.getChild(tr, cell)
   return DOM.getFirstChild(td)
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:10,代码来源:decoratorpanel.py

示例6: onError

 def onError(self, html, statusCode):
     if statusCode == 404 and self.allowEdit:
         self.editor = None
         self.originalText = ""
         DOM.setInnerHTML(self.getElement(), '')
         self.editButton = Label("create "+unescape(self.templateName))
         self.editButton.addStyleName("link")
         self.editButton.addStyleName("ContentPanelEditLink")
         self.editButton.addClickListener(EventDelegate("onClick", self, self.onEditContentClick))
         ComplexPanel.insert(self, self.editButton, self.getElement(), len(self.children))
         return
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:11,代码来源:TemplatePanel.py

示例7: pygwt_processMetas

def pygwt_processMetas():
    import DOM
    global pygwt_moduleNames
    metas = doc().get_elements_by_tag_name("meta")
    for i in range(metas.props.length):
        meta = metas.item(i)
        name = DOM.getAttribute(meta, "name")
        if name == "pygwt:module":
            content = DOM.getAttribute(meta, "content")
            if content:
                pygwt_moduleNames.append(content)
    return pygwt_moduleNames
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:12,代码来源:__pyjamas__.py

示例8: createTD

 def createTD(self, styleName) :
     """ Create a new table cell with a specific style name.
      
         @param styleName the style name
         @return the new cell {@link Element}
     """
     tdElem = DOM.createTD()
     inner = DOM.createDiv()
     DOM.appendChild(tdElem, inner)
     self.setStyleName(tdElem, styleName)
     self.setStyleName(inner, styleName + "Inner")
     print "createTd", styleName
     return tdElem
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:13,代码来源:decoratorpanel.py

示例9: attachToElement

 def attachToElement(self, element, widget):    
     events = DOM.getEventsSunk(widget.getElement())
     widget.unsinkEvents(events)
     widget.setElement(element)
     widget.sinkEvents(events)
     self.adopt(widget, None)
     self.children.append(widget)
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:7,代码来源:TemplatePanel.py

示例10: __init__

    def __init__(self, panel):
        self.panel = panel

        DOM.setStyleAttribute(panel.getElement(), "position", "relative")

        topElem = panel.getWidgetElement(TOP)
        bottomElem = panel.getWidgetElement(BOTTOM)

        self.expandToFitParentHorizontally(topElem)
        self.expandToFitParentHorizontally(bottomElem)
        self.expandToFitParentHorizontally(panel.getSplitElement())

        self.panel.expandToFitParentUsingCssOffsets(panel.container)

        # Snap the bottom wrapper to the bottom side.
        DOM.setStyleAttribute(bottomElem, "bottom", "0")
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:16,代码来源:vertsplitpanel.py

示例11: send

def send(self, varBody = None):
    DOM.dom_logging(log, "XMLHTTPRequest.send", varBody)
    msg = "send"
    if varBody:
        msg = "%s('%s')" % (msg, str(varBody), )

    log.ThugLogging.add_behavior_warn("[Microsoft XMLHTTP ActiveX] %s" % (msg, ))
    log.ThugLogging.add_behavior_warn("[Microsoft XMLHTTP ActiveX] Fetching from URL %s (method: %s)" % (self.bstrUrl, self.bstrMethod, ))
    log.ThugLogging.log_exploit_event(self._window.url,
                                      "Microsoft XMLHTTP ActiveX",
                                      "Send",
                                      forward = False,
                                      data = {
                                                "method" : self.bstrMethod,
                                                "url"    : str(self.bstrUrl)
                                             }
                                     )

    try:
        response = self._window._navigator.fetch(self.bstrUrl,
                                                 method        = self.bstrMethod,
                                                 headers       = self.requestHeaders,
                                                 body          = varBody,
                                                 redirect_type = "Microsoft XMLHTTP Exploit")
    except:
        log.ThugLogging.add_behavior_warn('[Microsoft XMLHTTP ActiveX] Fetch failed')

    self.responseHeaders = response.headers
    self.responseBody    = response.content

    contenttype = self.responseHeaders.get('content-type', None)
    if contenttype is None:
        return

    if 'text/html' in contenttype:
        doc = w3c.parseString(self.responseBody)

        window = DOM.Window.Window(self.bstrUrl, doc, personality = log.ThugOpts.useragent)
        #window.open(self.bstrUrl)

        dft = DOM.DFT.DFT(window)
        dft.run()
        return

    handler = log.MIMEHandler.get_handler(contenttype)
    if handler:
        handler(url, html)
开发者ID:execgit,项目名称:thugdom,代码行数:47,代码来源:MicrosoftXMLHTTP.py

示例12: setTemplateText

    def setTemplateText(self, text):
        """
        Set the template text; if the template is not HTML, a subclass could override this
        to pre-process the text into HTML before passing it to the default implementation.
        """
        if self.allowEdit:
            self.originalText = text
        # If we have children, remove them all first since we are trashing their DOM
        for child in List(self.children):
            self.remove(child)
        
        DOM.setInnerHTML(self.getElement(), text)
        self.elementsById = {}
        self.links = []
        self.metaTags = {}
        self.forms = []
        self.metaTagList = []
        
        # Make the ids unique and store a pointer to each named element
        for node in DOM.walkChildren(self.getElement()):
            #console.log("Passing node with name %s", node.nodeName)
            if node.nodeName == "META":
                name = node.getAttribute("name")
                content = node.getAttribute("content")
                console.log("Found meta %o name %s content %s", node, name, content)
                self.metaTags[name] = content
                self.metaTagList.append(node)
            elif node.nodeName == "BODY":
                self.body = node
            elif node.nodeName == "TITLE":
                self.title = DOM.getInnerText(node)
            elif node.nodeName == "FORM":
                self.forms.append(node)

            nodeId = DOM.getAttribute(node, "id")
            if nodeId:
                self.elementsById[nodeId] = node
                DOM.setAttribute(node, "id", self.id+":"+node.id)
            nodeHref = DOM.getAttribute(node, "href")
            if nodeHref:
                self.links.append(node)
                
        self.loaded = True
        if self.attached:
            self.attachWidgets()
            self.widgetsAttached = True
            
        if self.allowEdit:
            self.editor = None
            self.editButton = Label("edit "+unescape(self.templateName))
            self.editButton.addStyleName("link")
            self.editButton.addStyleName("ContentPanelEditLink")
            self.editButton.addClickListener(EventDelegate("onClick", self, self.onEditContentClick))
            ComplexPanel.insert(self, self.editButton, self.getElement(), len(self.children))

        self.notifyLoadListeners()
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:56,代码来源:TemplatePanel.py

示例13: __init__

 def __init__(self, initialValue="", target="", method="POST"):
     Widget.__init__(self);
     self.id = "rte"+hash(self)
     fck = createFCK("fck"+self.id)
     fck.Height = "600px"
     self.setElement(DOM.createForm())
     DOM.setAttribute(self.element, "method", "POST")
     DOM.setAttribute(self.element, "target", target)
     JS("""
     var rte = this;
     this.element.onsubmit = function() {
         $wnd.setTimeout(function() { rte.onSave.call(rte) }, 0);
         return false;
     }
     """)
     self.setID(self.id)
     self.addStyleName("gwt-RichTextEditor")
     fck.Value = initialValue
     fck.BasePath = "fckeditor/"
     fck.Config.CustomConfigurationsPath = "../../fckconfig.js"
     fck.pyjsObject = self
     self.loaded = False
     self.saveListeners = []
     self.pendingHTML = None
     html = fck.CreateHtml()
     #console.log("fck html = %s", html)
     html = html
     DOM.setInnerHTML(self.getElement(), html)
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:28,代码来源:RichTextEditor.py

示例14: __init__

    def __init__(self, width, height):
        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"
开发者ID:AwelEshetu,项目名称:cwm,代码行数:18,代码来源:Canvas.py

示例15: buildDOM

    def buildDOM(self):
        topDiv = self.getWidgetElement(TOP)
        bottomDiv = self.getWidgetElement(BOTTOM)
        splitDiv = self.getSplitElement()

        DOM.appendChild(self.getElement(), self.container)

        DOM.appendChild(self.container, topDiv)
        DOM.appendChild(self.container, splitDiv)
        DOM.appendChild(self.container, bottomDiv)

        # The style name is placed on the table rather than splitElem
        # to allow the splitter to be styled without interfering
        # with layout.

        thumb_html = '<img src="splitPanelThumb.png" />'
        DOM.setInnerHTML(splitDiv, "<div class='vsplitter' " +
                                   "style='text-align:center'>" +
                                   thumb_html + "</div>")

        self.addScrolling(topDiv)
        self.addScrolling(bottomDiv)
开发者ID:pombredanne,项目名称:pyjamas-desktop,代码行数:22,代码来源:vertsplitpanel.py


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