Pyxel Magic Command
概要
Jypyter(notebook/lab)・VSCodeまたはGoogle ColabでコードセルのPythonコードをPyxelを使ってiframe(ブラウザ)上で実行するマジックコマンドです。
使い方
マジックコマンドの追加
コードセルに以下のコードを貼り付けて実行しマジックコマンドを登録してください。カーネルやランタイムを再起動する度に再実行する必要があります。
%pip install -q -U pysmagic pyxelmagic
from pyxelmagic import register_pyxelmagic
register_pyxelmagic()
マジックコマンドの使い方
コードセルの冒頭に以下のようにマジックコマンドを記述してください。実行するとアウトプットにiframeが表示されてその中でコードセルのコードがPyScriptで実行されます。
%%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内で実行します。
%%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と同じです。
Metadata
Release files for pyxelmagic 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyxelmagic-1.1.1.tar.gz | 4.1 kB | Without provenance | Details for pyxelmagic-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyxelmagic-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for pyxelmagic-1.1.1-py3-none-any.whl |
Total release size: 8.7 kB
Release files / pyxelmagic-1.1.1.tar.gz
| Download URL | pyxelmagic-1.1.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03e2453f3c3030b79e5f26e361f15c35056edf58d871de5e9769016ee70a2baa
|
|
BLAKE2b-256 checksum How to use checksums |
bdfb2a65c697f2a9644ed8c635b2b75ca2c91f1996cc7f749be8b00c9b41d702
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Release files / pyxelmagic-1.1.1-py3-none-any.whl
| Download URL | pyxelmagic-1.1.1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7e479b9791dc46ac17e04cc0361a2640300dc07781210e0b3f223773c34c2f2
|
|
BLAKE2b-256 checksum How to use checksums |
1c71c32a5c19944d9ae92d088e920d52fd29b16d45f6ba49c12b49d050e3dc94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Security for pyxelmagic 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.