Commit 63ad1018 authored by Romain Casati's avatar Romain Casati

Fix locals access in p5.

parent 953d42f5
......@@ -5,7 +5,7 @@ Core part of p5 wrapper. p5.js loading is done here.
import pkg_resources
import js
import pyodide
from basthon import kernel
__author__ = "Romain Casati"
......@@ -71,8 +71,8 @@ class P5SketchBase(object):
n.style.visibility = "visible"
# sending node to Basthon for rendering
pyodide.Basthon.display_event({"display_type": "p5",
"content": node})
kernel.display_event({"display_type": "p5",
"content": node})
self._node = node
return self
......
......@@ -2,7 +2,7 @@
A scope/namespace manager for managing tricky 'from p5 import *'.
"""
import pyodide
from basthon import kernel
__author__ = "Romain Casati"
......@@ -22,7 +22,7 @@ class NSManager(object):
(2) call to update_attributes after import
"""
def __init__(self, attributes):
self._initial_ns = set(pyodide.Basthon._namespace.keys())
self._initial_ns = set(kernel.locals().keys())
self._attributes = attributes.copy()
self._tracked_attributes = None
......@@ -36,10 +36,10 @@ class NSManager(object):
if self._tracked_attributes is None:
self._init_tracked_attributes(namespace)
if namespace is None:
namespace = pyodide.Basthon._namespace
namespace = kernel.locals()
for a in self._tracked_attributes:
namespace[a] = getattr(from_object, a)
def get_from_global_ns(self, name):
""" Bonus: get an attribute from global (Basthon) namespace. """
return pyodide.Basthon._namespace.get(name)
return kernel.locals().get(name)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment