I am trying to create links in some html that call a  webservice (not 
external links) .  A couple of GWT examples on the internet show creating 
and anchor, attaching a click listener, then adding it to an HtmlPanel 
using the div id.  I cannot seem to get this to work in pyjs. Can some 
please confirm this bug or slap me for doing something stupid.  Either are 
welcomed. The example code below boils the problem as compactly as I can. 
 It Illustrates inability to attach a widget with click listening to an 
HTMLPanel.  Thanks!!!  If I can get this working I promise to update the 
existing example pyjs <https://github.com/pyjs/pyjs> / 
examples<https://github.com/pyjs/pyjs/tree/master/examples>
 / anchor <https://github.com/pyjs/pyjs/tree/master/examples/anchor> / 
Anchor.py. 

from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.Anchor import Anchor
from pyjamas.ui.Hyperlink import Hyperlink
from pyjamas import Window
from pyjamas.ui.HTML import HTML
from pyjamas.ui.HTMLPanel import HTMLPanel
from pyjamas.ui.Label import Label

def onClick(sender):
    Window.alert('I was Clicked')
if __name__ == '__main__':
    # EXAMPLE 1 (broken)- attach click listener to anchor then to html panel
    html1=HTMLPanel("<a id ='link1'>link1 - htmlpanel, anchor, anchor </a>")
    a1 = Anchor()
    a1.addClickListener(onClick)
    html1.add(a1, "link1")
    # EXAMPLE 2 - attach click listener to label
    label = Label('link2 - label')
    label.addClickListener(onClick)
    # EXAMPLE 3 - attach click listener to hyperlink
    a2 = Hyperlink('link3 - hyperlink')
    a2.addClickListener(onClick)
    # EXAMPLE 4 (broken)- attach click listener to hyperlink then to html 
panel
    html2=HTMLPanel("<div id ='link4'>link4 - htmlpanel, div, 
hyperlink</div>")
    html2.add(a2, "link4")
    
    RootPanel().add(html1) #does not work
    RootPanel().add(label) #works
    RootPanel().add(a2) #works
    RootPanel().add(html2) #does not work      


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to