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


Python DOM.createAnchor方法代码示例

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


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

示例1: _apply

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import createAnchor [as 别名]
    def _apply(self):
        formatter = self.m_editor.getFormatter()

        link = self.m_webPageText.getText().strip()
        if not link:
            return False

        print self.m_origAnchorStart, self.m_origAnchorEnd

        if (self.m_origAnchorStart is not None)  and  self.m_fillOutCB.getValue():
            # Expand selection to these bounds
            self.m_range.setRange(self.m_origAnchorStart, self.m_origAnchorEnd)

        # Ensure the selection hasn't changed, or at least changes to the
        # expanded bounds we want
        Selection.setRange(self.m_range)

        targetText = self.m_targetText.getText()

        if self.m_range.isCursor():
            # Insert into a single cursor location
            newEle = DOM.createAnchor()
            newEle.setHref(link)
            newEle.setInnerText(targetText)

            sp = self.m_range.getStartPoint()
            startNode = sp.getTextNode()
            offset = sp.getOffset()
            print "sp", sp, startNode, offset
            parentEle = startNode.parentElement
            text = startNode.data

            if offset == 0:
                parentEle.insertBefore(newEle, startNode)

            else:
                if offset < text.length():
                    # Split this in two and insert the node between
                    startNode.splitText(offset)

                parentEle.insertAfter(newEle, startNode)

            Selection.setRange(Range(newEle))

        elif targetText != self.m_origTargetText:
            # Replace whatever was selected with this text
            ele = self.m_range.surroundContents()
            newEle = DOM.createAnchor()
            newEle.href = link
            newEle.innerText = targetText
            ele.parentElement.replaceChild(newEle, ele)

            Selection.setRange(Range(newEle))
        else:
            formatter.createLink(link)


        return True
开发者ID:Afey,项目名称:pyjs,代码行数:60,代码来源:RichTextToolbar.py

示例2: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import createAnchor [as 别名]
 def __init__(self, disclosurePanel, **kwargs):
     element = kwargs.pop('Element', DOM.createAnchor())
     SimplePanel.__init__(self, element)
     self.disclosurePanel = disclosurePanel
     element = self.getElement()
     DOM.setAttribute(element, "href", "javascript:void(0);");
     DOM.setStyleAttribute(element, "display", "block")
     self.sinkEvents(Event.ONCLICK)
     self.setStyleName("header")
开发者ID:anandology,项目名称:pyjamas,代码行数:11,代码来源:DisclosurePanel.py

示例3: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import createAnchor [as 别名]
    def __init__(self, text="", asHTML=False, Element=None, **kwargs):

        if Element is None:
            Element = DOM.createDiv()
        self.anchorElem = DOM.createAnchor()
        self.setElement(Element)
        DOM.appendChild(self.getElement(), self.anchorElem)

        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-Hyperlink"
        if text:
            if asHTML:
                kwargs['HTML'] = text
            else:
                kwargs['Text'] = text
        if not kwargs.has_key('TargetHistoryToken'):
            kwargs['TargetHistoryToken'] = None

        Widget.__init__(self, **kwargs)
        ClickHandler.__init__(self)
开发者ID:Afey,项目名称:pyjs,代码行数:21,代码来源:Hyperlink.py

示例4: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import createAnchor [as 别名]
    def __init__(self, worksheet, id):
        SimplePanel.__init__(self)
        MouseHandler.__init__(self)
        self._id = id
        self._worksheet = worksheet
        insert_new_cell = HTML("", StyleName="insert_new_cell")
        insert_new_cell.addClickListener(InsertListener(worksheet, self._id))
        input_prompt = HTML("In [%d]:" % self._id, Element=DOM.createSpan(),
                StyleName="input_prompt")
        cell_input = InputArea(worksheet, self._id, StyleName='cell_input')
        evaluate_button = HTML("evaluate", Element=DOM.createAnchor(),
                StyleName="eval_button", Visible=False)
        evaluate_button.getElement().setAttribute("href", "")
        evaluate_button.addClickListener(EvaluateListener(self))
        evaluate_button.addMouseListener(self)
        output_delimiter = HTML("", StyleName="output_delimiter")
        output_prompt = HTML("Out[%d]:" % self._id, Element=DOM.createSpan(),
                StyleName="output_prompt")
        cell_output = HTML("", Element=DOM.createSpan(),
                StyleName="cell_output")
        output_prompt.setVisible(False)
        p = FlowPanel(StyleName="cell")
        p.add(insert_new_cell)
        p.add(input_prompt)
        p.add(cell_input)
        p.add(evaluate_button)
        p.add(output_delimiter)
        p.add(output_prompt)
        p.add(cell_output)
        self.add(p)

        self._cell_input = cell_input
        self._cell_output = cell_output
        self._output_prompt = output_prompt
        self._evaluate_button = evaluate_button

        self._mouse_in = False
开发者ID:certik,项目名称:sympy_gamma,代码行数:39,代码来源:nb.py


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