• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyjamas.DOM类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: set_main_frame

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


示例2: setWidth

    def setWidth(self, width):

        self.fontsize = math.floor(width / self.cols)
        AbsolutePanel.setWidth(self, "%dpx" % (self.cols*self.fontsize))

        ratio = self.fontsize / self.fontheight 
        DOM.setStyleAttribute(self.getElement(), 'fontSizeAdjust', str(ratio))
开发者ID:brodybits,项目名称:pyjs,代码行数:7,代码来源:textconsole.py


示例3: onBrowserEvent

 def onBrowserEvent(self, event):
     etype = DOM.eventGetType(event)
     if etype in MOUSE_EVENTS:
         if self._mousePreventDefault:
             DOM.eventPreventDefault(event)
         return fireMouseEvent(self._mouseListeners, self, event)
     return False
开发者ID:anandology,项目名称:pyjamas,代码行数:7,代码来源:MouseListener.py


示例4: onreadystatechange

    def onreadystatechange():
        if xhtoj.readyState == 4:
            jsnode = 0
            if xhtoj.status == 200:
                txt = xhtoj.responseText

                jsnode = None

                if idname:
                    jsnode = DOM.getElementById(idname)

                if jsnode is None:
                    jsnode = DOM.createElement('script')

                #tst = DOM.createElement('html')
                #tst.innerHTML = str

                activate_javascript(txt)
                if not on_load_fn is None:
                    wnd().alert(on_load_fn)
                    # eval(on_load_fn)
                    test_fn()

                return 1
            else:
                jsnode = DOM.getElementById(idname)

                if not jsnode is None:
                    jsnode.innerHTML = xhtoj.status
开发者ID:Afey,项目名称:pyjs,代码行数:29,代码来源:dynamic.py


示例5: setSplitPosition

    def setSplitPosition(self, px):
        splitElem = self.panel.getSplitElement()

        rootElemHeight = DOM.getOffsetHeight(self.panel.container)
        splitElemHeight = DOM.getOffsetHeight(splitElem)

        # layout not settled, set height to what it _should_ be... yuk.
        if splitElemHeight == 0:
            splitElemHeight = 7

        if rootElemHeight < splitElemHeight:
            return

        newBottomHeight = rootElemHeight - px - splitElemHeight
        if px < 0:
            px = 0
            newBottomHeight = rootElemHeight - splitElemHeight
        elif newBottomHeight < 0:
            px = rootElemHeight - splitElemHeight
            newBottomHeight = 0

        self.updateElements(self.panel.getWidgetElement(0),
                       splitElem,
                       self.panel.getWidgetElement(1),
                       px, px + splitElemHeight, newBottomHeight)
开发者ID:certik,项目名称:pyjamas,代码行数:25,代码来源:vertsplitpanel.py


示例6: validarParametrosMatriz

    def validarParametrosMatriz():
        lm1 = DOM.getElementById("lm1")
        lm1 = lm1.value
        cm1 = DOM.getElementById("cm1")
        cm1 = cm1.value
        lm2 = DOM.getElementById("lm2")
        lm2 = lm2.value
        cm2 = DOM.getElementById("cm2")
        cm2 = cm2.value
        if not lm1 or not lm2:
            Window.alert("Informe o numero de linhas da matriz M1 e M2.")
            return False

        if lm1 != lm2:
            Window.alert("A quantidade de linhas da matriz M1 deve ser igual a da matriz M2 para operação de soma.")
            return False

        if lm1 > "5" or lm2 > "5" or len(lm1) != 1 or len(lm2) != 1:
            Window.alert("A quantidade de linhas da matriz M1 e da matriz M2, deve ser menor ou igual a 5.")
            return False

        if not cm1 or not cm2:
            Window.alert("Informe o numero de colunas da matriz M1 e M2.")
            return False

        if cm1 != cm2:
            Window.alert("A quantidade de colunas da matriz M1 deve ser igual a da matriz M2 para operação de soma.")
            return False

        if cm1 > "7" or cm2 > "7" or len(cm1) != 1 or len(cm2) != 1:
            Window.alert("A quantidade de colunas da matriz M1 e da matriz M2, deve ser menor ou igual a 7.")
            return False
        return True
开发者ID:nielsonsantana,项目名称:emath,代码行数:33,代码来源:PopupPagina.py


示例7: onDrop

    def onDrop(self, event):
        dt = event.dataTransfer

        item = dt.getData("Text")
        data = json.decode(item)
        if 'name' in data and 'age' in data:
            age = data['age']
            name = data['name']
            self.removeStyleName('dragover')
            if self.age_is_ok(age):
                self.addStudent(name, age)
                dt.dropEffect = 'copy'

                self.addStyleName('flash')
                def removeFlash(timer):
                    self.removeStyleName('flash')

                Timer(250, notify=removeFlash)
            else:
                dt.dropEffect = 'none'
                self.addMessage('student could not be added')
                # setting dropEffect to 'none' should be sufficient to notify
                # that the drop failed, but
                # we need to cheat a bit for now...
                # this is the only reason for parent id in data
                item_parent_id = data['parent']
                item_parent = self.parent.containerFromId(item_parent_id)
                item_parent.addStyleName('drop_fail')
            # prevent default allows onDragEnd to see the dropEffect we set here
        DOM.eventPreventDefault(event)
开发者ID:anandology,项目名称:pyjamas,代码行数:30,代码来源:DNDTest.py


示例8: onClick

    def onClick(self, sender=None):
        """
        Called when the user finishes clicking on this button.
        The default behavior is to fire the click event to
        listeners. Subclasses that override onClickStart() should
        override this method to restore the normal widget display.
        """
        # Allow the click we're about to synthesize to pass through to the
        # superclass and containing elements. Element.dispatchEvent() is
        # synchronous, so we simply set and clear the flag within this method.
        self.allowClick = True

        # Mouse coordinates are not always available (e.g., when the click is
        # caused by a keyboard event).
        evt = None # we NEED to initialize evt, to be in the same namespace
                   # as the evt *inside* of JS block

        # We disallow setting the button here, because IE doesn't provide the
        # button property for click events.

        # there is a good explanation about all the arguments of initMouseEvent
        # at: https://developer.mozilla.org/En/DOM:event.initMouseEvent

        DOM.buttonClick(self.getElement())
        self.allowClick = False
开发者ID:Afey,项目名称:pyjs,代码行数:25,代码来源:CustomButton.py


示例9: onDragStart

 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     target = Widget(Element=target)
     id = target.getID()
     dt.setData("Text", "Dropped %s" % target.getID())
     dt.effectAllowed = 'copy'
     if id == 'imgdrag1':
         parent = self.getParent()
         while not hasattr(parent, 'h2'):
             parent = parent.getParent()
         dt.setDragImage(parent.h2.getElement(), 10, 10)
     elif id == 'imgdrag2':
         dt.setDragImage(doc().getElementById('logo'), 10, 10)
     elif id == 'imgdrag3':
         # OK, it's a bit of a cheat, but the following works on current
         # Opera, IE, Firefox, Safari, Chrome.
         ctx = GWTCanvas(50, 50)
         self.makeCanvasImg(ctx)
         try:
             img = DOM.createImg()
             DOM.setAttribute(img, 'src', ctx.canvas.toDataURL())
             dt.setDragImage(img, 25, 25)
         except:
             dt.setDragImage(ctx.canvas, 25, 25)
开发者ID:anandology,项目名称:pyjamas,代码行数:25,代码来源:DNDTest.py


示例10: addMessage

 def addMessage(self, text):
     d = datetime.now().strftime("%x %X")
     li = DOM.createElement('li')
     DOM.setInnerHTML(li,
                      '<dt class="time">%s</dt><dd class="txt">%s</dd>' % (
                      d, text))
     DOM.insertChild(self.element, li, 0)
开发者ID:anandology,项目名称:pyjamas,代码行数:7,代码来源:DNDTest.py


示例11: buildDOM

    def buildDOM(self):

        leftDiv = self.getWidgetElement(0)
        rightDiv = self.getWidgetElement(1)
        splitDiv = self.getSplitElement()

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

        DOM.appendChild(self.container, leftDiv)
        DOM.appendChild(self.container, splitDiv)
        DOM.appendChild(self.container, rightDiv)

        # Sadly, this is the only way I've found to get vertical
        # centering in this case. The usually CSS hacks (display:
        # table-cell, vertical-align: middle) don't work in an
        # absolute positioned DIV.
        thumb_html = '<img src="splitPanelThumb.png" />'
        DOM.setInnerHTML(splitDiv,
            "<table class='hsplitter' height='100%' cellpadding='0' " +
                "cellspacing='0'><tr><td align='center' valign='middle'>" +
                thumb_html +
                "</td></tr></table>")

        self.addScrolling(leftDiv)
        self.addScrolling(rightDiv)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:25,代码来源:horizsplitpanel.py


示例12: setHTML

 def setHTML(self, html):
     """Set the face's contents as html."""
     self.face = DOM.createDiv()
     UIObject.setStyleName(self.button, self.face, self.STYLENAME_HTML_FACE,
                           True)
     DOM.setInnerHTML(self.face, html)
     self.button.updateButtonFace()
开发者ID:Afey,项目名称:pyjs,代码行数:7,代码来源:CustomButton.py


示例13: findTextPoint

def findTextPoint(node, offset):
    """
    If the found range is not on a text node, this finds the cooresponding
    text node to where the selection is.  If it is on a text node, just
    directly creates the endpoint from it.

    @param node node returned as an endpoint of a range
    @param offset offset returned to the endpoint of a range
    @return A range end point with a proper (or None) text node
    """
    if DOM.getNodeType(node) == DOM.TEXT_NODE:
        res = RangeEndPoint(node, offset)
    else:
        # search backwards unless this is after the last node
        dirn = offset >= DOM.getChildCount(node)
        child = (DOM.getChildCount(node) == 0) and node or DOM.getChild(node, dirn and (offset - 1) or offset)
        # Get the previous/next text node
        text = RangeUtil.getAdjacentTextElement(child, dirn)
        if text is None:
            # If we didn't find a text node in the preferred direction,
            # try the other direction
            dirn = not dirn
            text = RangeUtil.getAdjacentTextElement(child, dirn)

        res = RangeEndPoint(text, dirn)

    return res
开发者ID:luiseduardohdbackup,项目名称:pyjs,代码行数:27,代码来源:Range.py


示例14: fillText

    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,代码行数:25,代码来源:SVGCanvas.py


示例15: moveControl

    def moveControl(self, mouse_x, mouse_y, first_move=False):
        handle_height = DOM.getIntAttribute(self.handle, "offsetHeight")
        widget_height = self.getOffsetHeight()
        height_range = widget_height - 10 # handle height is hard-coded
        relative_y = mouse_y - (handle_height / 2)
        if relative_y < 0:
            relative_y = 0
        if relative_y >= height_range:
            relative_y = height_range

        # turn round (bottom to top) for x
        relative_y = height_range - relative_y

        handle_width = DOM.getIntAttribute(self.handle, "offsetWidth")
        widget_width = self.getOffsetWidth()
        length_range = widget_width - 10 # handle width is hard-coded
        relative_x = mouse_x - (handle_width / 2)
        if relative_x < 0:
            relative_x = 0
        if relative_x >= length_range:
            relative_x = length_range

        val_diff_x = self.max_value_x - self.min_value_x
        new_value_x = ((val_diff_x * relative_x) / length_range) + \
                      self.min_value_x

        val_diff_y = self.max_value_y - self.min_value_y
        new_value_y = ((val_diff_y * relative_y) / height_range) + \
                      self.min_value_y

        new_value = [new_value_x, new_value_y]
        new_value = self.processValue(new_value)
        self.setControlPos(new_value)
        self.setValue(new_value)
开发者ID:anandology,项目名称:pyjamas,代码行数:34,代码来源:AreaSlider.py


示例16: onImagesLoaded

 def onImagesLoaded(self, imagesHandles):
     self.clock = imagesHandles[0]
     el = self.clock.getElement()
     self.width = DOM.getIntAttribute(el, "width")
     self.height = DOM.getIntAttribute(el, "height")
     self.setWidth("%d" % self.width)
     self.setHeight("%d" % self.height)
开发者ID:anandology,项目名称:pyjamas,代码行数:7,代码来源:Widgets.py


示例17: setStyleName

def setStyleName(element, style, add):

    oldStyle = DOM.getAttribute(element, "className")
    if oldStyle is None:
        oldStyle = ""
    idx = oldStyle.find(style)

    # Calculate matching index
    lastPos = len(oldStyle)
    while idx != -1:
        if idx == 0 or (oldStyle[idx - 1] == " "):
            last = idx + len(style)
            if (last == lastPos) or ((last < lastPos) and (oldStyle[last] == " ")):
                break
        idx = oldStyle.find(style, idx + 1)

    if add:
        if idx == -1:
            DOM.setAttribute(element, "className", oldStyle + " " + style)
    else:
        if idx != -1:
            if idx == 0:
              begin = ''
            else:
              begin = oldStyle[:idx-1]
            end = oldStyle[idx + len(style):]
            DOM.setAttribute(element, "className", begin + end)
开发者ID:anandology,项目名称:pyjamas,代码行数:27,代码来源:UIObject.py


示例18: __init__

    def __init__(self, **kwargs):
        """ Creates an empty vertical split panel.
        """
        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-VerticalSplitPanel"
        if kwargs.has_key('Element'):
            element = kwargs.pop('Element')
        else:
            element = DOM.createDiv()
        SplitPanel.__init__(self, element,
                            DOM.createDiv(),
                            self.preventBoxStyles(DOM.createDiv()),
                            self.preventBoxStyles(DOM.createDiv()),
                            **kwargs)

        self.container = self.preventBoxStyles(DOM.createDiv())
        self.buildDOM()

        self.impl = ImplVerticalSplitPanel(self)

        self.setSplitPosition("50%")

        # Captures the height of the top container when drag resizing starts.
        self.initialTopHeight = 0

        # Captures the offset of a user's mouse pointer during drag resizing.
        self.initialThumbPos = 0

        self.lastSplitPosition = ""
开发者ID:certik,项目名称:pyjamas,代码行数:28,代码来源:vertsplitpanel.py


示例19: __init__

    def __init__(self, headerText, isOpen=False, **kwargs):

        self.handlers = []
        self.content = None

        # this is awkward: VerticalPanel is the composite,
        # so we get the element here, and pass it in to VerticalPanel.
        element = None
        if kwargs.has_key('Element'):
            element = kwargs.pop('Element')

        self.mainPanel = VerticalPanel(Element=element)

        self.header = ClickableHeader(self)
        self.contentWrapper = SimplePanel()
        self.mainPanel.add(self.header)
        self.mainPanel.add(self.contentWrapper)
        DOM.setStyleAttribute(self.contentWrapper.getElement(),
                              "padding", "0px");
        DOM.setStyleAttribute(self.contentWrapper.getElement(),
                              "overflow", "hidden");

        self.isOpen = isOpen

        self.headerObj = DefaultHeader(headerText, self)
        self.setHeader(self.headerObj)

        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-DisclosurePanel"
        Composite.__init__(self, self.mainPanel, **kwargs)

        self.setContentDisplay()
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:31,代码来源:DisclosurePanel.py


示例20: 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 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)
开发者ID:certik,项目名称:pyjamas,代码行数:29,代码来源:splitpanel.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyjamas.Factory类代码示例发布时间:2022-05-25
下一篇:
Python utils.process函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap