/pyjs/tests/test012.py
http://pyjamas.googlecode.com/ · Python · 25 lines · 20 code · 5 blank · 0 comment · 4 complexity · 26b3097617196ab3f5eb1a796a6b113b MD5 · raw file
- import DOM
- class Widget:
- def __init__(self):
- self.attached = False
- def setParent(self, parent):
- self.parent = parent
- if parent == None:
- self.onDetach()
- elif parent.attached:
- self.onAttach()
- def onAttach(self):
- if self.attached:
- return
- self.attached = True
- DOM.setEventListener(self.getElement(), self)
-
- def onDetach(self):
- if not self.attached:
- return
- self.attached = False
- DOM.setEventListener(self.getElement(), None)