Permalink
Newer
Older
100644 39 lines (35 sloc) 1.38 KB
Luke Kenneth Casson Leighton
Jul 16, 2010
1
import pyjd
2
from pyjamas.ui.RootPanel import RootPanel
3
from pyjamas import DOM
Luke Kenneth Casson Leighton
Jul 16, 2010
4
from pyjamas.ui.Anchor import Anchor
5
from pyjamas.ui.Hyperlink import Hyperlink
6
from pyjamas import Window
7
from pyjamas.ui.HTML import HTML
8
from pyjamas.ui.HTMLPanel import HTMLPanel
9
from pyjamas.ui.Label import Label
10
from pyjamas.ui.Image import Image
11
from pyjamas.ui.HorizontalPanel import HorizontalPanel
Luke Kenneth Casson Leighton
Jul 16, 2010
12
13
def onClick(sender):
14
Window.alert('I was Clicked')
15
Luke Kenneth Casson Leighton
Jul 16, 2010
16
if __name__ == '__main__':
17
pyjd.setup("public/Anchor.html")
18
19
# EXAMPLE 1
20
a1 = Anchor(Widget = HTML('Test 1: Anchor to external site using HTML widget.'), Href='http://pyjs.org', Title = 'Test1')
21
RootPanel().add(a1)
22
# EXAMPLE 2
23
label = Label(text = 'Test 2: Click listener added to a label.')
24
label.addClickListener(onClick)
25
RootPanel().add(label)
26
# EXAMPLE 3
27
a2 = Hyperlink(text = 'Hyperlink', Element = DOM.createSpan())
28
a2.addClickListener(onClick)
29
html2=HTMLPanel("Test 3: <span id ='t3'></span> added to HTMLPanel with click listener.")
30
html2.add(a2, "t3")
31
RootPanel().add(html2)
32
# EXAMPLE 4
33
hpanel = HorizontalPanel()
34
hpanel.append(HTML('Test 4: Anchor to external site using Image widget'))
35
a3 = Anchor(Widget = Image('http://pyjs.org/assets/images/pyjs.128x128.png'), Href='http://pyjs.org', Title = 'Test4')
36
hpanel.append(a3)
37
38
RootPanel().add(hpanel)
39
pyjd.run()