예제 #1
0
class BrowserDOMAgent(Agent):
    def __init__(self, name=None):
        super().__init__(name=name)
        self.document = get_document()
        self.document.head.appendChild(Style(style))
        self.ul = Ul(class_='zen-log')
        self.document.body.appendChild(self.ul)

    @on_event('*')
    @on_message('*')
    def every_frame(self, frame):
        li = Li()
        prefix = FRAME_PREFIX[frame.kind]
        text = frame_template.format(prefix=prefix,
                                     source=frame.source,
                                     name=frame.name)
        data = frame.data
        if data and not (len(data.keys()) == 1 and 'text' in data):
            text += data_template.format(data=pformat(data))

        li.innerHTML = text
        self.ul.appendChild(li)
예제 #2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from wdom.tag import Ul, Li

ul = Ul()
li1 = Li('item1')
li2 = Li('item2')
...

ul.appendChild(li1)
ul.appendChild(li2)
...
print(ul.html_noid)

# by append
ul2 = Ul()
ul2.append(Li('item1'), Li('item2'))
print(ul2.html_noid)
예제 #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from wdom.tag import Ul

ul = Ul()
ul.innerHTML = '''\
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
'''

print(ul.html_noid)  # <ul><li>...

# Accessing child nodes
# for child in ul.childNodes:
#     print(child.html)

# or, first/lastChild
print(ul.firstChild.html)
print(ul.lastChild.html)

# excluding Text nodes
for child in ul.children:
    print(child.html)

# first/lastElementChild
print(ul.firstElementChild.html)
print(ul.lastElementChild.html)
예제 #4
0
from wdom.tag import Ul

ul = Ul()
ul.innerHTML = '''\
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
'''

print(ul.html_noid)  # <ul><li>...

# Accessing child nodes
# for child in ul.childNodes:
#     print(child.html)

# or, first/lastChild
print(ul.firstChild.html)
print(ul.lastChild.html)

# excluding Text nodes
for child in ul.children:
    print(child.html)

# first/lastElementChild
print(ul.firstElementChild.html)
print(ul.lastElementChild.html)
예제 #5
0
from wdom.tag import Ul, Li

ul = Ul()
li1 = Li('item1')
li2 = Li('item2')
...

ul.appendChild(li1)
ul.appendChild(li2)
...
print(ul.html_noid)

# by append
ul2 = Ul()
ul2.append(Li('item1'), Li('item2'))
print(ul2.html_noid)
예제 #6
0
 def __init__(self, name=None):
     super().__init__(name=name)
     self.document = get_document()
     self.document.head.appendChild(Style(style))
     self.ul = Ul(class_='zen-log')
     self.document.body.appendChild(self.ul)