-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
100 lines (75 loc) · 3.28 KB
/
index.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<html>
<!--
MIT License
Copyright (c) 2019 J M Evans (g4 <at> novadsp <dot> com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Dual roles:
python -m http.server --directory=/path/to/html
or (assuming electron is in the path)
electron .
In alphabetical order, a very big thank you for wonderful work:
https://github.com/brython-dev/brython
https://github.com/vakata/jstree
https://github.com/vitmalina/w2ui
-->
<head>
<!-- Insert this line above script imports -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<!-- normal script imports etc -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.7.1/brython.js" ></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.7.1/brython_stdlib.js" ></script>
<link rel="stylesheet" type="text/css" href="scripts/w2ui/w2ui-1.5.rc1.css" />
<script type="text/javascript" src="scripts/w2ui/w2ui-1.5.rc1.js" ></script>
<!-- The CSS has been very slightly modified to match colors and font with w2ui -->
<link rel="stylesheet" href="scripts/jstree/style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.8/jstree.min.js"></script>
<!-- this is where the python code lives. -->
<script type="text/python" src="main.py"></script>
<script>
// general purpose helper for debugging stubborn issues!
// call this from python via document.js_dump()
function js_dump(jsobj) {
console.log(jsobj);
}
//
function main() {
// python application instance
document.pyapp = null;
// debug dumper
__BRYTHON__.js_dump = js_dump;
// run up the Python converter. This spins a webworker
// thread, returns a promise ...
brython({debug:1});
// just to show what can be done in Javascript
console.log('__BRYTHON__:' + __BRYTHON__);
// it is educational to view this in the debugger
// empty object
var jsx = {};
// python object
var pyo = __BRYTHON__.jsobj2pyobj(jsx);
// and back to javascript
var jso = __BRYTHON__.pyobj2jsobj(pyo);
}
</script>
</head>
<body onload="main()">
<div id="main" style="width: 100%; height: 100%;"></div>
</body>
</html>