Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Basthon
Basthon Kernel
Commits
f49a7dc9
Commit
f49a7dc9
authored
Oct 02, 2022
by
Romain Casati
Browse files
Python 3: Fix in p5 (arguments should be converted back to Javascript).
parent
06072edc
Changes
1
Hide whitespace changes
Inline
Side-by-side
packages/kernel-python3/src/modules/p5/p5/_global.py
View file @
f49a7dc9
...
...
@@ -23,7 +23,7 @@ __email__ = "romain.casati@basthon.fr"
try
:
# Python 3.10
from
pyodide.ffi
import
JsProxy
from
pyodide.ffi
import
JsProxy
,
to_js
as
_to_js
def
isJsProxy
(
obj
):
return
isinstance
(
obj
,
JsProxy
)
...
...
@@ -38,6 +38,9 @@ except ImportError:
def
isJsFunc
(
obj
):
return
type
(
obj
).
__name__
==
'JsBoundMethod'
def
_to_js
(
x
,
**
kwargs
):
return
x
__all__
=
[
'run'
,
'show'
,
'stop'
,
'load_library'
,
'update_variables'
]
def
__dir__
():
return
__all__
...
...
@@ -103,6 +106,7 @@ class FunctionWrapper(object):
self
.
_func_name
=
func_name
def
__call__
(
self
,
*
args
):
args
=
tuple
(
_to_js
(
a
)
for
a
in
args
)
# calling corresponding function from global instance
return
getattr
(
_instance
,
self
.
_func_name
)(
*
args
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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