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


Python DOM.setElemAttribute方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [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)
开发者ID:anandology,项目名称:pyjamas,代码行数:37,代码来源:Tree.py

示例2: setBackgroundColor

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def setBackgroundColor(self, color):
        """
        Sets the background color of the canvas element.

        @param color the background color.
        """
        # set style value
        style="background-color: "+str(color)+";"
        # set the canvas background color with the style attribute
        DOM.setElemAttribute(self.canvas, "style", style)
开发者ID:Afey,项目名称:pyjs,代码行数:12,代码来源:SVGCanvas.py

示例3: setPixelHeight

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def setPixelHeight(self, height):
        """
        Sets the CSS height of the canvas in pixels.

        @param height the height of the canvas in pixels
        """
        height = int(height)
        self.pixelHeight = height
        FocusWidget.setHeight(self, height)
        DOM.setElemAttribute(self.canvas, "height", str(height))
        self._set_base_transform()
开发者ID:Afey,项目名称:pyjs,代码行数:13,代码来源:SVGCanvas.py

示例4: strokeRect

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
 def strokeRect(self, startX, startY, width, height):
     # if stroke style is None or width is 0 we don't do anything
     if self.ctx["stroke"] is None or self.ctx["stroke-width"] == 0: return
     # create a rect element
     rect = self._make_rect(startX, startY, width, height)
     # apply stroke styles
     self._apply_stroke_styles(rect)
     # no fill
     DOM.setElemAttribute(rect, "fill", "transparent")
     # add the rect element to the canvas
     self._addElementSVG(rect)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:13,代码来源:SVGCanvas.py

示例5: setPixelWidth

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def setPixelWidth(self, width):
        """
        Sets the CSS width in pixels for the canvas.

        @param width width of the canvas in pixels
        """
        width = int(width)
        self.pixelWidth = width
        FocusWidget.setWidth(self, width)
        DOM.setElemAttribute(self.canvas, "width", str(width))
        self._set_base_transform()
开发者ID:Afey,项目名称:pyjs,代码行数:13,代码来源:SVGCanvas.py

示例6: doRESTQuery

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def doRESTQuery(self, url, timer):
        """this is a totally different from an RPC call in that we have to
           dynamically add script tags to the DOM when we want to query the 
           REST API. These rely on callbacks in the DOM so we can either add 
           them dynamically or pre-define them in public/Main.html. 
           Once we've done that have to wait for the response.
           Which means we need to provide a listener for the timer"""

        new_script = DOM.createElement("script")
        DOM.setElemAttribute(new_script, "src", url)
        DOM.setElemAttribute(new_script, "type","text/javascript")
        doc().body.appendChild(new_script)
        self.timer.schedule(100)
开发者ID:brodybits,项目名称:pyjs,代码行数:15,代码来源:Photos.py

示例7: load_tinymce

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def load_tinymce(self):

        # activate tinymce
        new_script = DOM.createElement("script")
        new_script.innerHTML = """
var ed = tinyMCE.get('%s');
ed.init();
ed.render();
""" % self.editor_id

        print new_script.innerHTML

        DOM.setElemAttribute(new_script, "type","text/javascript")
        doc().body.appendChild(new_script)
开发者ID:brodybits,项目名称:pyjs,代码行数:16,代码来源:TinyMCEditor.py

示例8: fillText

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def fillText(self, text, startX, startY, maxWidth=None):
        """
        Places text, at the specified start
        coords, according to the current fillstyle.

        @param startX x coord of the top left corner in the destination space
        @param startY y coord of the top left corner in the destination space
        @param maxWidth maximum width of text
        """
        # create an SVG text element
        text_elem = self._createElementSVG("text")
        # integerize the coordinates
        xy = self._integerize(startX, startY)
        # add the size and position
        DOM.setElemAttribute(text_elem, "x", str(xy[0]))
        DOM.setElemAttribute(text_elem, "y", str(xy[1]))
        if maxWidth is not None:
            DOM.setElemAttribute(text_elem, "textLength", str(maxWidth))
        # add the fill styles
        style = "font:"+self.ctx["font"]+";fill:"+str(self.ctx["fill"])
        DOM.setElemAttribute(text_elem, "style", style)
        # now add the text
        DOM.setInnerText(text_elem, text)
        # add the rect element to the canvas
        self._addElementSVG(text_elem)
开发者ID:Afey,项目名称:pyjs,代码行数:27,代码来源:SVGCanvas.py

示例9: stroke

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
 def stroke(self):
     # if the path is empty we don't do anything
     if self.last_point is None: return
     # if stroke style is None or width is 0 we don't do anything
     if self.ctx["stroke"] is None or self.ctx["stroke-width"] == 0: return
     # create a path element
     path = self._createElementSVG("path")
     # add the current path draw string
     DOM.setElemAttribute(path, "d", self.path_string)
     # apply stroke styles
     self._apply_stroke_styles(path)
     # no fill
     DOM.setElemAttribute(path, "fill", "transparent")
     # add the path element to the canvas
     self._addElementSVG(path)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:17,代码来源:SVGCanvas.py

示例10: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
 def __init__(self, defs_elem, elem_type, width, height):
     # save defs
     self.defs_elem = defs_elem
     # save dimensions of canvas as floats
     self.canvas_width = float(width)
     self.canvas_height = float(height)
     # create the gradient element
     self.elem = self._createElementSVG(elem_type)
     # make a unique id
     self.id = "grad"+str(DOM.getChildCount(defs_elem) + 1)
     # set the element's id
     DOM.setElemAttribute(self.elem, "id", self.id)
     # set for canvas-based coordinates
     DOM.setElemAttribute(self.elem, "gradientUnits", "userSpaceOnUse")
     # add the new element to defs
     DOM.appendChild(defs_elem, self.elem)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:18,代码来源:SVGCanvas.py

示例11: _apply_current_transforms

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def _apply_current_transforms(self):
        # if the current transform group already has elements
        if DOM.getChildCount(self.ctx["transform_group"]) > 0:
            # we create a new one
            group = self._createElementSVG("g")
            # add a new transform group to the canvas
            DOM.appendChild(self.canvas, group)
            # and make it the current tranform group
            self.ctx["transform_group"] = group
        # build the transform spec
        # just to make the next line shorter
        mx = self.ctx["matrix"]
        transform = "matrix("+str(mx[0])+","+str(mx[1])+","+str(mx[2])+","+str(mx[3])+","+str(mx[4])+","+str(mx[5])+") "
        # we need to update the transform attribute of the current group
#        print "Apply transform:",transform
        DOM.setElemAttribute(self.ctx["transform_group"], "transform", transform)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:18,代码来源:SVGCanvas.py

示例12: transfer_tinymce

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def transfer_tinymce(self):

        new_script = DOM.createElement("script")
        new_script.innerHTML = """
var ed = tinyMCE.get('%s');
var data = ed.getContent({'format': 'raw'});
frame = document.getElementById('__edit_%s');
frame.innerText = data;
ed.save();
ed.remove();
""" % (self.editor_id, self.editor_id)

        self.editor_created = False

        DOM.setElemAttribute(new_script, "type","text/javascript")
        doc().body.appendChild(new_script)
        self.hide()
        t = Timer(notify=self)
        t.scheduleRepeating(1000)
开发者ID:brodybits,项目名称:pyjs,代码行数:21,代码来源:TinyMCEditor.py

示例13: strokeRect

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def strokeRect(self, startX, startY, width, height):
        """
        Strokes a rectangle defined by the supplied arguments.

        @param startX x coord of the top left corner
        @param startY y coord of the top left corner
        @param width width of the rectangle
        @param height height of the rectangle
        """
        # if stroke style is None or width is 0 we don't do anything
        if self.ctx["stroke"] is None or self.ctx["stroke-width"] == 0: return
        # create a rect element
        rect = self._make_rect(startX, startY, width, height)
        # apply stroke styles
        self._apply_stroke_styles(rect)
        # no fill
        DOM.setElemAttribute(rect, "fill", "transparent")
        # add the rect element to the canvas
        self._addElementSVG(rect)
开发者ID:Afey,项目名称:pyjs,代码行数:21,代码来源:SVGCanvas.py

示例14: drawImage

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
    def drawImage(self, img, *args):
        # create an image element:
        # <image xlink:href="firefox.jpg" x="0" y="0" height="50px" width="50px"/>
        # The way to do this is to create a clipping container and place the image inside that,
        # using scaling and positioning to approximate some of the effect of sourceXY and destXY
        # for now, we ignore all this
        #
        # get the image size and URL - image may be a Image Widget or an <img> Element
        if isinstance(img, Widget):     # Image widget
            img_elem = img.getElement()
            url = img.getUrl()
        else:   # <img> element
            img_elem = img
            url = DOM.getAttribute(img, "src")
        # determine all parms
        sourceXY = None
        sourceWH = None
        destXY = None
        destWH = None
        # get the parms that are specified
        if len(args) == 8:  # all parms specified
            sourceXY = (args[0], args[1])
            sourceWH = (args[2], args[3])
            destXY = (args[4], args[5])
            destWH = (args[6], args[7])
        elif len(args) == 4:    # only destXY and destWH are specified
            destXY = (args[0], args[1])
            destWH = (args[2], args[3])
        elif len(args) == 2:    # we just get destXY
            destXY = (args[0], args[1])
            # by default we keep the same size
            destWH = (img_elem.width, img_elem.height)
        else:
            raise TypeError("Wrong number of arguments for SVGCanvas.drawImage")

        # sourceWH and destWH determine the scaling
        # sourceXY and scaling determine where to place the image inside the clipping container
        # destXY determines where to place the clipping container

        # for now just create an SVG image element:
        # <image xlink:href="firefox.jpg" x="0" y="0" height="50px" width="50px"/>
#        print 'Create: <image xlink:href="'+url+'" x="'+str(destXY[0])+'" y="'+str(destXY[1])+'" height="'+str(destWH[1])+'px" width="'+str(destWH[0])+'px"/>'
        image = self._createElementSVG("image")
        # set the URL
        image.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", url); 
        # set the pos/dimensions
        DOM.setElemAttribute(image, "x", str(int(destXY[0])))
        DOM.setElemAttribute(image, "y", str(int(destXY[1])))
        DOM.setElemAttribute(image, "width", str(int(destWH[0])))
        DOM.setElemAttribute(image, "height", str(int(destWH[1])))
        # add the element to the canvas
        self._addElementSVG(image)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:54,代码来源:SVGCanvas.py

示例15: _make_rect

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setElemAttribute [as 别名]
 def _make_rect(self, startX, startY, width, height):
     # create a rect element
     rect = self._createElementSVG("rect")
     # integerize the coordinates
     xy = self._integerize(startX, startY)
     wh = self._integerize(width, height)
     # add the size and position
     DOM.setElemAttribute(rect, "x", str(xy[0]))
     DOM.setElemAttribute(rect, "y", str(xy[1]))
     DOM.setElemAttribute(rect, "width", str(wh[0]))
     DOM.setElemAttribute(rect, "height", str(wh[1]))
     # return the element
     return rect
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:15,代码来源:SVGCanvas.py


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