From f407054b3b0bf3f7eb9d6c1721f1c591f6f6b555 Mon Sep 17 00:00:00 2001 From: BruceSherwood Date: Wed, 29 Jul 2020 22:15:50 -0500 Subject: [PATCH] Implement fixes from GlowScript --- labextension/vpython/src/glowcommlab.js | 8 +++++++- vpython/vpython.py | 1 + vpython/vpython_libraries/glowcomm.html | 9 ++++++++- vpython/vpython_libraries/glowcomm.js | 8 +++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/labextension/vpython/src/glowcommlab.js b/labextension/vpython/src/glowcommlab.js index e5090b1..0bd1c96 100644 --- a/labextension/vpython/src/glowcommlab.js +++ b/labextension/vpython/src/glowcommlab.js @@ -537,7 +537,13 @@ function decode(data) { } } else if (textattrs.indexOf(attr) > -1) { if (attr == 'choices') { // menu choices to be wrapped in a list - val = m[3].split(' ') + val = m[3].slice(2,-2) + val = val.replace(/'/g, '') // remove quotes + val = val.replace(/,/g, '') // remove commas + let s = val.split(' ') + val = [] + let a + for (a of s) {val.push(a)} } else { // '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '
' val = m[3].replace(/
/g, "\n") diff --git a/vpython/vpython.py b/vpython/vpython.py index 78921ad..a95946f 100644 --- a/vpython/vpython.py +++ b/vpython/vpython.py @@ -3339,6 +3339,7 @@ class controls(baseObj): def setup(self, args): super(controls, self).__init__() ## get idx, attrsupdt from baseObj ## default values of common attributes + self._disabled = False self._constructing = True argsToSend = [] objName = args['_objName'] diff --git a/vpython/vpython_libraries/glowcomm.html b/vpython/vpython_libraries/glowcomm.html index 4ade8a6..51f5fa5 100644 --- a/vpython/vpython_libraries/glowcomm.html +++ b/vpython/vpython_libraries/glowcomm.html @@ -459,7 +459,13 @@ } } else if (textattrs.indexOf(attr) > -1) { if (attr == 'choices') { // menu choices to be wrapped in a list - val = m[3].split(' ') + val = m[3].slice(2,-2) + val = val.replace(/'/g, '') // remove quotes + val = val.replace(/,/g, '') // remove commas + let s = val.split(' ') + val = [] + let a + for (a of s) {val.push(a)} } else { // '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '
' val = m[3].replace(/
/g, "\n") @@ -792,6 +798,7 @@ cfg.objName = obj cfg.bind = control_handler cfg = fix_location(cfg) + console.log(cfg.choices) glowObjs[idx] = menu(cfg) if (cfg['selected'] === 'None') { cfg['selected'] = null diff --git a/vpython/vpython_libraries/glowcomm.js b/vpython/vpython_libraries/glowcomm.js index 9e6a9b5..276c083 100644 --- a/vpython/vpython_libraries/glowcomm.js +++ b/vpython/vpython_libraries/glowcomm.js @@ -509,7 +509,13 @@ function decode(data) { } } else if (textattrs.indexOf(attr) > -1) { if (attr == 'choices') { // menu choices to be wrapped in a list - val = m[3].split(' ') + val = m[3].slice(2,-2) + val = val.replace(/'/g, '') // remove quotes + val = val.replace(/,/g, '') // remove commas + let s = val.split(' ') + val = [] + let a + for (a of s) {val.push(a)} } else { // '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '
' val = m[3].replace(/
/g, "\n")