-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtestMinipy.py
40 lines (36 loc) · 933 Bytes
/
testMinipy.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from guy import Guy,FULLSCREEN
import asyncio,datetime
class Minipy(Guy):
size=(300,200)
txt="3 * '#'"
__doc__="""
<style>
div#back form {display:inline}
</style>
<script>
async function test(txt) {
document.querySelector("#r").innerHTML = await self.post( txt )
}
</script>
<div id='back'>
<h3>minipy</h3>
<form onsubmit="test(this.txt.value); return false">
<input id='n' name="txt" value="<<txt>>" onfocus="var val=this.value; this.value=''; this.value= val;" />
<button> run </button>
</form>
<button onclick="self.exit()">exit</button>
</div>
<script>
document.querySelector("#n").focus()
</script>
<div id=r></div>"""
def post(self,txt):
try:
return eval(txt, globals(), locals())
except Exception as e:
return "error:%s"%e
if __name__ == "__main__":
x=Minipy()
x.run(log=True)