-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui_control.py
27 lines (24 loc) · 873 Bytes
/
gui_control.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
# from vpython.no_notebook import stop_server
import keyboard
from sys import exit
import os
import signal
# https://github.com/BruceSherwood/vpython-jupyter/issues/36
def monitor_terminate():
if keyboard.is_pressed('q'):
print("Exit function triggered. Sending the kill signal.")
# stop_server() # this didn't work for me, hangs on this function usually
# print("Server stopped.")
os.kill(os.getpid(), signal.SIGINT)
exit()
def monitor_pause():
if keyboard.is_pressed('p'):
print("Pause triggered.")
while True:
if keyboard.is_pressed('r'):
print("Resuming")
return
if keyboard.is_pressed('q'):
print("Exit function triggered. Sending the kill signal.")
os.kill(os.getpid(), signal.SIGINT)
exit()