forked from epfl-mobots/vpl-teacher-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch_tk_jws.py
executable file
·37 lines (26 loc) · 968 Bytes
/
launch_tk_jws.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
#!/usr/bin/python3
# Author: Yves Piguet, EPFL
# Please don't redistribute without author's permission.
# server app launcher with tkinter user interface
from vpl3tt.launch import launch
from vpl3tt.tkapp import Application
from vpl3tt.server_thymio import ThymioWebSocketServer
import threading
import asyncio
class ApplicationJWS(Application):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.server_thymio = None
def thymio_thread():
asyncio.set_event_loop(asyncio.new_event_loop())
self.server_thymio = ThymioWebSocketServer()
self.server_thymio.run()
try:
from vpl3tt.thymio import Connection
Connection.serial_default_port()
self.ws_thymio = threading.Thread(target=thymio_thread)
self.ws_thymio.start()
except Exception:
self.disable_serial()
if __name__ == "__main__":
launch(ApplicationJWS)