-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
76 lines (58 loc) · 2.08 KB
/
start.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
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
import os
import time
import webview
import logging
import threading
class Api():
def addItem(self, title):
print('Added item %s' % title)
def removeItem(self, item):
print('Removed item %s' % item)
def editItem(self, item):
print('Edited item %s' % item)
def toggleItem(self, item):
print('Toggled item %s' % item)
def toggleFullscreen(self):
webview.windows[0].toggle_fullscreen()
def cppyyDemo(self, msg):
#--begin-- cppyy test region begion
import cppyy
cppyy.cppdef("""
class MyClass {
public:
MyClass(int i) : m_data(i) {}
virtual ~MyClass() {}
virtual int add_int(int i) { return m_data + i; }
int m_data;
};""")
from cppyy.gbl import MyClass
c=MyClass(42)
cppyy.cppdef("""
void say_hello(MyClass* m) {
std::cout << "Hello, the number is: " << m->m_data << std::endl;
}""")
MyClass.say_hello=cppyy.gbl.say_hello
logging.warn('hello world' * 80)
for i in range(10):
c.add_int(3)
c.say_hello()
#--end-- cppyy test region begion
logging.warn('--begin-- to call cppyyDemo'*80+msg)
c.say_hello()
logging.warn('--end-- to call cppyyDemo'*80+msg)
def errorDemo(self, seconds):
raise Exception('face error ')
pass
def sleepDemo(self, seconds):
logging.warning('--begin-- backend sleepting' + str(threading.current_thread().ident) )
time.sleep(seconds)
logging.warning('--end-- backend sleepting' + str(threading.current_thread().ident))
return threading.current_thread().ident
pass
if __name__ == '__main__':
api = Api()
webview.create_window('Todos magnificos', 'assets/index.html', js_api=api, min_size=(600, 450))
#debug will enable right click menu
#http_server will enable a http server, which works better than files:/ protocol
#cef engine works better for all os
webview.start(debug=True, http_server=True, gui='cef')