Skip to content

Commit f407054

Browse files
committed
Implement fixes from GlowScript
1 parent 5838bea commit f407054

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

labextension/vpython/src/glowcommlab.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,13 @@ function decode(data) {
537537
}
538538
} else if (textattrs.indexOf(attr) > -1) {
539539
if (attr == 'choices') { // menu choices to be wrapped in a list
540-
val = m[3].split(' ')
540+
val = m[3].slice(2,-2)
541+
val = val.replace(/'/g, '') // remove quotes
542+
val = val.replace(/,/g, '') // remove commas
543+
let s = val.split(' ')
544+
val = []
545+
let a
546+
for (a of s) {val.push(a)}
541547
} else {
542548
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
543549
val = m[3].replace(/<br>/g, "\n")

vpython/vpython.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3339,6 +3339,7 @@ class controls(baseObj):
33393339
def setup(self, args):
33403340
super(controls, self).__init__() ## get idx, attrsupdt from baseObj
33413341
## default values of common attributes
3342+
self._disabled = False
33423343
self._constructing = True
33433344
argsToSend = []
33443345
objName = args['_objName']

vpython/vpython_libraries/glowcomm.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,13 @@
459459
}
460460
} else if (textattrs.indexOf(attr) > -1) {
461461
if (attr == 'choices') { // menu choices to be wrapped in a list
462-
val = m[3].split(' ')
462+
val = m[3].slice(2,-2)
463+
val = val.replace(/'/g, '') // remove quotes
464+
val = val.replace(/,/g, '') // remove commas
465+
let s = val.split(' ')
466+
val = []
467+
let a
468+
for (a of s) {val.push(a)}
463469
} else {
464470
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
465471
val = m[3].replace(/<br>/g, "\n")
@@ -792,6 +798,7 @@
792798
cfg.objName = obj
793799
cfg.bind = control_handler
794800
cfg = fix_location(cfg)
801+
console.log(cfg.choices)
795802
glowObjs[idx] = menu(cfg)
796803
if (cfg['selected'] === 'None') {
797804
cfg['selected'] = null

vpython/vpython_libraries/glowcomm.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,13 @@ function decode(data) {
509509
}
510510
} else if (textattrs.indexOf(attr) > -1) {
511511
if (attr == 'choices') { // menu choices to be wrapped in a list
512-
val = m[3].split(' ')
512+
val = m[3].slice(2,-2)
513+
val = val.replace(/'/g, '') // remove quotes
514+
val = val.replace(/,/g, '') // remove commas
515+
let s = val.split(' ')
516+
val = []
517+
let a
518+
for (a of s) {val.push(a)}
513519
} else {
514520
// '\n' doesn't survive JSON transmission, so in vpython.py we replace '\n' with '<br>'
515521
val = m[3].replace(/<br>/g, "\n")

0 commit comments

Comments
 (0)