File: MainTest.py

package info (click to toggle)
pyjamas 0.7~%2Bpre2-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,656 kB
  • ctags: 12,331
  • sloc: python: 74,493; php: 805; sh: 291; makefile: 59; xml: 9
file content (43 lines) | stat: -rw-r--r-- 878 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from pyjamas import Window

def log(text):
    Window.alert(text)
    #JS("""
    #   console.log(text)
    #""")

def global_printable(text):
    log(text)

class MainTest:
    def onModuleLoad(self):

        s = StoringObject()

        s.save(self.printable)
        s.message = "called from storing object via self.printable"
        s.call()

        s.save(getattr(self,'printable'))
        s.message = "called from storing object using getattr(self, 'printable') "
        s.call()

        s.save(global_printable)
        s.message = "called from storing object using global_printable"
        s.call()

    @staticmethod
    def printable(text):
        log(text)
    
class StoringObject:
    def save(self,func):
        self.func = func
    def call(self):
        self.func(self.message)



if __name__ == '__main__':
    app = MainTest()
    app.onModuleLoad()