|
26 | 26 | 'quad', 'radio', 'ring', 'simple_sphere', 'sleep', 'slider', 'sphere',
|
27 | 27 | 'standardAttributes', 'text', 'textures', 'triangle', 'vertex',
|
28 | 28 | 'wtext']
|
29 |
| -vec = vector # synonyms in GlowScript |
30 |
| - |
31 |
| -def __checkisnotebook(): # returns True if running in Jupyter notebook |
32 |
| - try: |
33 |
| - shell = get_ipython().__class__.__name__ |
34 |
| - if shell == 'ZMQInteractiveShell': # Jupyter notebook or qtconsole? |
35 |
| - return True |
36 |
| - elif shell == 'TerminalInteractiveShell': # Terminal running IPython? |
37 |
| - return False |
38 |
| - else: |
39 |
| - return False # Other type (?) |
40 |
| - except NameError: |
41 |
| - return False # Probably standard Python interpreter |
42 |
| -_isnotebook = __checkisnotebook() |
43 |
| - |
44 |
| -if _isnotebook: |
45 |
| - #### Imports for Jupyter VPython |
46 |
| - import IPython |
47 |
| - if IPython.__version__ >= '4.0.0' : |
48 |
| - import ipykernel |
49 |
| - import notebook |
50 |
| - from ipykernel.comm import Comm |
51 |
| - if (ipykernel.__version__ >= '5.0.0'): |
52 |
| - |
53 |
| - import asyncio |
54 |
| - async def wsperiodic(): |
55 |
| - while True: |
56 |
| - if ws_queue.qsize() > 0: |
57 |
| - data = ws_queue.get() |
58 |
| - d = json.loads(data) |
59 |
| - for m in d: |
60 |
| - # Must send events one at a time to GW.handle_msg because bound events need the loop code: |
61 |
| - msg = {'content':{'data':[m]}} # message format used by notebook |
62 |
| - baseObj.glow.handle_msg(msg) |
63 |
| - |
64 |
| - await asyncio.sleep(0) |
65 |
| - |
66 |
| - loop = asyncio.get_event_loop() |
67 |
| - loop.create_task(wsperiodic()) |
68 |
| - |
69 |
| - else: |
70 |
| - import IPython.html.nbextensions |
71 |
| - from IPython.kernel.comm.comm import Comm |
72 |
| - from IPython.display import HTML |
73 |
| - from IPython.display import display |
74 |
| - from IPython.display import Javascript |
75 |
| - from IPython.core.getipython import get_ipython |
76 |
| - from jupyter_core.paths import jupyter_data_dir |
77 |
| - from . import __version__, __gs_version__ |
78 | 29 |
|
79 | 30 | __p = platform.python_version()
|
80 | 31 | _ispython3 = (__p[0] == '3')
|
@@ -379,7 +330,7 @@ def __del__(self):
|
379 | 330 | # and sent as a block to the browser at render times.
|
380 | 331 |
|
381 | 332 | class GlowWidget(object):
|
382 |
| - def __init__(self, wsport = None, wsuri = None): |
| 333 | + def __init__(self, wsport=None, wsuri=None): |
383 | 334 | global sender
|
384 | 335 | baseObj.glow = self
|
385 | 336 | if _isnotebook:
|
|
0 commit comments