Name | pyxelmagic JSON |
Version |
1.1.1
JSON |
| download |
home_page | None |
Summary | This Python package is a magic command that executes Python code in code cells on Jupyter and Google Colab using PyScript within an iframe. |
upload_time | 2024-11-13 12:18:01 |
maintainer | None |
docs_url | None |
author | Uniras |
requires_python | None |
license | MIT License |
keywords |
pyscript
jupyter
magic
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Pyxel Magic Command
## 概要
Jypyter(notebook/lab)・VSCodeまたはGoogle ColabでコードセルのPythonコードをPyxelを使ってiframe(ブラウザ)上で実行するマジックコマンドです。
## 使い方
### マジックコマンドの追加
コードセルに以下のコードを貼り付けて実行しマジックコマンドを登録してください。カーネルやランタイムを再起動する度に再実行する必要があります。
```python
%pip install -q -U pysmagic pyxelmagic
from pyxelmagic import register_pyxelmagic
register_pyxelmagic()
```
### マジックコマンドの使い方
コードセルの冒頭に以下のようにマジックコマンドを記述してください。実行するとアウトプットにiframeが表示されてその中でコードセルのコードがPyScriptで実行されます。
```python
%%runpyx 500 500
import pyxel
pyxel.init(160, 120)
def update():
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw():
pyxel.cls(0)
pyxel.rect(10, 10, 20, 20, 11)
pyxel.run(update, draw)
```
### マジックコマンド
#### %%runpyx
コードセルのコードをPyxelを使ってiframe内で実行します。
```jupyter
%%runpyx [width] [height] [gamepad] [packages] [js_src]
```
- width: iframeの幅を指定します。デフォルトは500です。
- height: iframeの高さを指定します。デフォルトは500です。
- gamepad: バーチャルゲームパッドを表示するか指定します。デフォルトはFalseです。
- packages: Pyhtonのパッケージを''で囲んだ文字列のJSON配列形式で指定します。デフォルトは'[]'です。
- js_src: 外部JavaScriptのURLを''で囲んだ文字列のJSON配列形式で指定します。デフォルトは'[]'です。
#### %%genpyx
セル内のPythonコードをPyScriptを用いてiframe内で実行するために生成したHTMLを表示するマジックコマンド
引数は%%runpyxと同じです。
Raw data
{
"_id": null,
"home_page": null,
"name": "pyxelmagic",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "PyScript, jupyter, magic",
"author": "Uniras",
"author_email": "tkappeng@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/bd/fb/2a65c697f2a9644ed8c635b2b75ca2c91f1996cc7f749be8b00c9b41d702/pyxelmagic-1.1.1.tar.gz",
"platform": null,
"description": "# Pyxel Magic Command\r\n\r\n## \u6982\u8981\r\n\r\nJypyter(notebook/lab)\u30fbVSCode\u307e\u305f\u306fGoogle Colab\u3067\u30b3\u30fc\u30c9\u30bb\u30eb\u306ePython\u30b3\u30fc\u30c9\u3092Pyxel\u3092\u4f7f\u3063\u3066iframe(\u30d6\u30e9\u30a6\u30b6)\u4e0a\u3067\u5b9f\u884c\u3059\u308b\u30de\u30b8\u30c3\u30af\u30b3\u30de\u30f3\u30c9\u3067\u3059\u3002\r\n\r\n## \u4f7f\u3044\u65b9\r\n\r\n### \u30de\u30b8\u30c3\u30af\u30b3\u30de\u30f3\u30c9\u306e\u8ffd\u52a0\r\n\r\n\u30b3\u30fc\u30c9\u30bb\u30eb\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u5b9f\u884c\u3057\u30de\u30b8\u30c3\u30af\u30b3\u30de\u30f3\u30c9\u3092\u767b\u9332\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u30ab\u30fc\u30cd\u30eb\u3084\u30e9\u30f3\u30bf\u30a4\u30e0\u3092\u518d\u8d77\u52d5\u3059\u308b\u5ea6\u306b\u518d\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\r\n\r\n```python\r\n%pip install -q -U pysmagic pyxelmagic\r\nfrom pyxelmagic import register_pyxelmagic\r\n\r\nregister_pyxelmagic()\r\n```\r\n\r\n### \u30de\u30b8\u30c3\u30af\u30b3\u30de\u30f3\u30c9\u306e\u4f7f\u3044\u65b9\r\n\r\n\u30b3\u30fc\u30c9\u30bb\u30eb\u306e\u5192\u982d\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30de\u30b8\u30c3\u30af\u30b3\u30de\u30f3\u30c9\u3092\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u5b9f\u884c\u3059\u308b\u3068\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u306biframe\u304c\u8868\u793a\u3055\u308c\u3066\u305d\u306e\u4e2d\u3067\u30b3\u30fc\u30c9\u30bb\u30eb\u306e\u30b3\u30fc\u30c9\u304cPyScript\u3067\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002\r\n\r\n```python\r\n%%runpyx 500 500\r\n\r\nimport pyxel\r\n\r\npyxel.init(160, 120)\r\n\r\ndef update():\r\n if pyxel.btnp(pyxel.KEY_Q):\r\n pyxel.quit()\r\n\r\ndef draw():\r\n pyxel.cls(0)\r\n pyxel.rect(10, 10, 20, 20, 11)\r\n\r\npyxel.run(update, draw)\r\n```\r\n\r\n### \u30de\u30b8\u30c3\u30af\u30b3\u30de\u30f3\u30c9\r\n\r\n#### %%runpyx\r\n\r\n\u30b3\u30fc\u30c9\u30bb\u30eb\u306e\u30b3\u30fc\u30c9\u3092Pyxel\u3092\u4f7f\u3063\u3066iframe\u5185\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002\r\n\r\n```jupyter\r\n%%runpyx [width] [height] [gamepad] [packages] [js_src]\r\n```\r\n\r\n- width: iframe\u306e\u5e45\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f500\u3067\u3059\u3002\r\n- height: iframe\u306e\u9ad8\u3055\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f500\u3067\u3059\u3002\r\n- gamepad: \u30d0\u30fc\u30c1\u30e3\u30eb\u30b2\u30fc\u30e0\u30d1\u30c3\u30c9\u3092\u8868\u793a\u3059\u308b\u304b\u6307\u5b9a\u3057\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306fFalse\u3067\u3059\u3002\r\n- packages: Pyhton\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092''\u3067\u56f2\u3093\u3060\u6587\u5b57\u5217\u306eJSON\u914d\u5217\u5f62\u5f0f\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f'[]'\u3067\u3059\u3002\r\n- js_src: \u5916\u90e8JavaScript\u306eURL\u3092''\u3067\u56f2\u3093\u3060\u6587\u5b57\u5217\u306eJSON\u914d\u5217\u5f62\u5f0f\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f'[]'\u3067\u3059\u3002\r\n\r\n#### %%genpyx\r\n\r\n\u30bb\u30eb\u5185\u306ePython\u30b3\u30fc\u30c9\u3092PyScript\u3092\u7528\u3044\u3066iframe\u5185\u3067\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u751f\u6210\u3057\u305fHTML\u3092\u8868\u793a\u3059\u308b\u30de\u30b8\u30c3\u30af\u30b3\u30de\u30f3\u30c9\r\n\r\n\u5f15\u6570\u306f%%runpyx\u3068\u540c\u3058\u3067\u3059\u3002\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "This Python package is a magic command that executes Python code in code cells on Jupyter and Google Colab using PyScript within an iframe.",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/uniras/PyxelMagic",
"Repository": "https://github.com/uniras/PyxelMagic"
},
"split_keywords": [
"pyscript",
" jupyter",
" magic"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1c71c32a5c19944d9ae92d088e920d52fd29b16d45f6ba49c12b49d050e3dc94",
"md5": "12fb150e7e5792bd4c354e2654631b58",
"sha256": "c7e479b9791dc46ac17e04cc0361a2640300dc07781210e0b3f223773c34c2f2"
},
"downloads": -1,
"filename": "pyxelmagic-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "12fb150e7e5792bd4c354e2654631b58",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4574,
"upload_time": "2024-11-13T12:17:59",
"upload_time_iso_8601": "2024-11-13T12:17:59.637678Z",
"url": "https://files.pythonhosted.org/packages/1c/71/c32a5c19944d9ae92d088e920d52fd29b16d45f6ba49c12b49d050e3dc94/pyxelmagic-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bdfb2a65c697f2a9644ed8c635b2b75ca2c91f1996cc7f749be8b00c9b41d702",
"md5": "ebbaaf7500cfe7fab420b9dda289a4ac",
"sha256": "03e2453f3c3030b79e5f26e361f15c35056edf58d871de5e9769016ee70a2baa"
},
"downloads": -1,
"filename": "pyxelmagic-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "ebbaaf7500cfe7fab420b9dda289a4ac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4119,
"upload_time": "2024-11-13T12:18:01",
"upload_time_iso_8601": "2024-11-13T12:18:01.338026Z",
"url": "https://files.pythonhosted.org/packages/bd/fb/2a65c697f2a9644ed8c635b2b75ca2c91f1996cc7f749be8b00c9b41d702/pyxelmagic-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-13 12:18:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "uniras",
"github_project": "PyxelMagic",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyxelmagic"
}