PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/pyjs/tests/test008.py

http://pyjamas.googlecode.com/
Python | 46 lines | 29 code | 17 blank | 0 comment | 0 complexity | 7f34f92cbdd8179a708feb26aa2f7e7e MD5 | raw file
 1import DOM
 2
 3class UIObject:
 4
 5    def getElement(self):
 6        return self.element
 7
 8    def setElement(self, element):
 9        self.element = element
10
11    def setStyleName(self, style):
12        DOM.setAttribute(self.element, "className", style)
13
14
15class Widget(UIObject):
16
17    def setParent(self, parent):
18        self.parent = parent
19
20
21class Panel(Widget):
22    pass
23
24
25class ComplexPanel(Panel):
26
27    def __init__(self):
28        self.children = []
29    
30    def add(self, widget):
31        self.children.append(widget)
32        widget.setParent(self)
33        return True
34
35
36class AbsolutePanel(ComplexPanel):
37
38    def __init__(self):
39        ComplexPanel.__init__(self)
40        self.setElement(DOM.createDiv())
41        DOM.setStyleAttribute(self.getElement(), "overflow", "hidden")
42    
43    def add(self, widget):
44        ComplexPanel.add(self, widget)
45        DOM.appendChild(self.getElement(), widget.getElement())
46        return True