this is a TODO reminder, to look at GWT widget "wrap" functions and duplicate them in pyjamas.ui. it's not necessary to add 25 identical "wrap" functions, one will do, at UIObject, using the pyjamas.ui.Factory class.
Original issue: http://code.google.com/p/pyjamas/issues/detail?id=418 (June 11, 2010 13:57:53)
My Google search led me here. I would love to see this feature added :)
I added a work around for lack of wrap. Code below should also be helpful in implementing the wrap function.
I was trying to update all the hyperlinks from HTML returned by a server with new click listeners. The GWT recommend way to accomplish this is with the wrap function (i.e, Hyperlink.wrap(elemement) which is not implemented yet for pyjs. To work around the issue I create I swap the DOM elements with a Widget. Then I assign the Widget's Click listener.
html4 = HTMLPanel(serverXml)
for idx, elem in enumerate(html4.findTags('a')):
parent = DOM.getParent(elem)
href = DOM.getAttribute(elem, 'href')
text = DOM.getInnerHTML(elem)
link =iHyperlink(text, href, Element = DOM.createSpan())
link.setID('link' + str(idx))
DOM.replaceChild(parent, link.getElement(), elem)