在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:kikocorreoso/brythonmagic开源软件地址:https://github.com/kikocorreoso/brythonmagic开源编程语言:Jupyter Notebook 94.4%开源软件介绍:BrythonmagicBrython magic for the Jupyter notebook. The brythonmagic provides you a cell magic, Tested onThe master branch of brythonmagic extension has been tested on:
InstallationYou should have Jupyter (notebook) already installed in order to use Brythonmagic. In case you don't have Jupyter installed you can follow the instructions on the Jupyter official page. Method 1) - Download this repo and on the brythonmagic downloaded folder type: python setup.py install Method 2) - Use pip (you will need to install git): python -m pip install git+https://github.com/kikocorreoso/brythonmagic.git
Then, load the extension in the notebook:
```python
%load_ext brythonmagic And, finally, load a stable brython js lib in the notebook using the following code: from brythonmagic import load_brython_stable
load_brython_stable() If you have any problem with the installation, please, open an issue. WARNINGIn order to load javascript libraries in a safety way you should try to use https instead of http when possible (read more here). If you don't trust the source and/or the source cannot be loaded using https then you could download the javascript library and load it from a local location. Brythonmagic doesn't load any javascript library and the user should take care about the security and should use trusted sources. You can load third party javascript libraries using the following code: from brythonmagic import load_js_lib
load_js_lib("https://url/to/your/lib.js") Usageexample: %%brython -c zone
# First of all, the import of some libraries
from browser import document, html
# All the elements will be inserted in the div with the "zone" id
zone = document['zone']
# We create a new div element
newdiv = html.DIV(Id = "new-div")
# Now we add some style
newdiv.style = {"padding": "5px",
"backgroundColor": "#ADD8E6"}
# We create a new link and add the link to a string
blink = html.A('brython',href="http://brython.info")
text = "Brython is really cool, look at "+ blink + " for more"
# Now we add the text to the div with id="new-div"
newdiv <= html.DIV(text)
# Finally, we add the newdiv to the outer div with id="zone"
zone <= newdiv You can use several options:
[WARNING] This options may change as the brythonmagic depending the development of Brython and/or Jupyter. To see some examples download the notebooks available in the repository and run it locally or see it in the nbviewer (you will loose the interactivity if you choose the second option). Also, you can take a look on the following video: http://youtu.be/adQzjuUX0kw Example notebooks (some options will not work due to changes in APIs)SupportIf you need Brython support, please, ask here: https://groups.google.com/forum/?fromgroups=#!forum/brython If you need IPython support, please, ask here: http://mail.scipy.org/mailman/listinfo/ipython-dev If you find a bug or want to propose a new feature open a new issue here: https://github.com/kikocorreoso/brythonmagic/issues If you want to improve the code, fork, commit and send a PR ;·D IDEASAdd an option to include *.py scripts? These *.py scripts should be
Brython compatible. Add an option to include a HTML structure so you don't have to create
the structure via Brython code? Add an option to run more than one Brython script in a code cell? Right
now, if you run a Brython code cell, the code in other cells will not
work anymore. Make it python 2.7 compatible. Create a setup.py to make it available via pip. CONTRIBUTORS
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论