Skip to content
This repository
Newer
Older
100644 101 lines (79 sloc) 2.568 kb
c930b73b » lkcl
2009-11-13 get shell example working under pyjd
1 import pyjd
2
d2d2524b » lkcl
2009-03-15 modal dialog box creating a desktop-like application
3 from pyjamas.ui.RootPanel import RootPanel
4 from pyjamas.ui.Controls import VerticalDemoSlider
5 from pyjamas import Window
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
6 from pyjamas.Timer import Timer
d2d2524b » lkcl
2009-03-15 modal dialog box creating a desktop-like application
7 from textconsole import TextWindow
8 from Screen import Screen
9
c930b73b » lkcl
2009-11-13 get shell example working under pyjd
10 try:
11 import pyjslib
12 except:
13 pass
5ad8a9cb » lkcl
2009-03-15 dynamic module load restructuring
14 import sys
15
d2d2524b » lkcl
2009-03-15 modal dialog box creating a desktop-like application
16 def slider_app():
17 b = VerticalDemoSlider(0, 100)
18 b.setWidth("20px")
19 b.setHeight("100px")
20 return b
21
22 def text_app():
23 w = TextWindow(80, 20, 400, 300)
24 RootPanel().add(w)
25 w.setText(0, 0, "hello")
26 w.setText(0, 1, "fred")
27 w.setText(0, 5, "goodbye")
28 for i in range(40):
29 for j in range(2):
30 w.setText(i, j+10, ".")
31 return w
32
5ad8a9cb » lkcl
2009-03-15 dynamic module load restructuring
33
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
34 class ShellApp():
35 def __init__(self):
8524c512 » lkcl
2009-03-15 add screen to rootpanel duh
36
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
37 self.GridTest = None
8524c512 » lkcl
2009-03-15 add screen to rootpanel duh
38
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
39 self.screen = Screen(Window.getClientWidth(), Window.getClientHeight())
40 w = text_app()
41 a = self.screen.add_app(w, "text 1", 400, 300)
42 a.show()
43 w = text_app()
44 a = self.screen.add_app(w, "text 2", 400, 300)
45 a.show()
46 w = slider_app()
47 a = self.screen.add_app(w, "s", 20, 100)
48 a.show()
5ad8a9cb » lkcl
2009-03-15 dynamic module load restructuring
49
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
50 RootPanel().add(self.screen)
5ad8a9cb » lkcl
2009-03-15 dynamic module load restructuring
51
85b8b4e6 » lkcl
2009-03-17 use dependency calculation even in module load
52 self.loading_apps = []
53 self.loading_app = None
54 self.loading_desc = None
55
56 self.load_app('../../gridtest/output/', 'GridTest', 'grid test')
57 self.load_app('../../widgets/output/', 'Widgets', 'clock')
58
59 def load_app(self, path, appname, description):
60 if self.loading_app is None:
61 self.add_app(path, appname, description)
62 else:
63 self.loading_apps.append((path, appname, description))
64
65 def add_app(self, path, appname, description):
66
67 self.loading_app = appname
68 self.loading_desc = description
69
c930b73b » lkcl
2009-11-13 get shell example working under pyjd
70 try:
71 sys.setloadpath(path)
72 pyjslib.preload_app_modules(sys.getloadpath(), [[appname]],
73 self, 1, None)
74 except:
75 pass
85b8b4e6 » lkcl
2009-03-17 use dependency calculation even in module load
76
77 def onTimer(self, timerid):
78 self.importDone()
5ad8a9cb » lkcl
2009-03-15 dynamic module load restructuring
79
8835a6f1 » lkcl
2009-03-16 bit of simplifying (not much...)
80 def importDone(self):
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
81
85b8b4e6 » lkcl
2009-03-17 use dependency calculation even in module load
82 mod = pyjslib.get_module(self.loading_app)
83 if mod is None:
84 Timer(500, self)
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
85 return
86
85b8b4e6 » lkcl
2009-03-17 use dependency calculation even in module load
87 g = mod.AppInit()
88 a = self.screen.add_app(g, self.loading_desc, 400, 300)
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
89 a.show()
64eff557 » xtfxme
2012-05-14 find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
90
85b8b4e6 » lkcl
2009-03-17 use dependency calculation even in module load
91 self.loading_desc = None
92 self.loading_app = None
93
94 if self.loading_apps:
95 path, appname, description = self.loading_apps.pop()
96 self.add_app(path, appname, description )
97
5ad8a9cb » lkcl
2009-03-15 dynamic module load restructuring
98 if __name__ == '__main__':
c930b73b » lkcl
2009-11-13 get shell example working under pyjd
99 pyjd.setup('./public/Shell.html')
c3e5d7ee » lkcl
2009-03-16 dynamic loading in shell example, of GridTest!
100 app = ShellApp()
c930b73b » lkcl
2009-11-13 get shell example working under pyjd
101 pyjd.run()
Something went wrong with that request. Please try again.