Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Romain Casati
Basthon Kernel
Commits
63ad1018
Commit
63ad1018
authored
Feb 02, 2021
by
Romain Casati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix locals access in p5.
parent
953d42f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
src/modules/p5/p5/_core.py
src/modules/p5/p5/_core.py
+3
-3
src/modules/p5/p5/_nsmanager.py
src/modules/p5/p5/_nsmanager.py
+4
-4
No files found.
src/modules/p5/p5/_core.py
View file @
63ad1018
...
...
@@ -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
...
...
src/modules/p5/p5/_nsmanager.py
View file @
63ad1018
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment