This Python package is a magic command that executes Python code in code cells on Jupyter and Google Colab using PyScript within an iframe.
Project description
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と同じです。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyxelmagic-1.1.1.tar.gz.
File metadata
- Download URL: pyxelmagic-1.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03e2453f3c3030b79e5f26e361f15c35056edf58d871de5e9769016ee70a2baa
|
|
| MD5 |
ebbaaf7500cfe7fab420b9dda289a4ac
|
|
| BLAKE2b-256 |
bdfb2a65c697f2a9644ed8c635b2b75ca2c91f1996cc7f749be8b00c9b41d702
|
File details
Details for the file pyxelmagic-1.1.1-py3-none-any.whl.
File metadata
- Download URL: pyxelmagic-1.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7e479b9791dc46ac17e04cc0361a2640300dc07781210e0b3f223773c34c2f2
|
|
| MD5 |
12fb150e7e5792bd4c354e2654631b58
|
|
| BLAKE2b-256 |
1c71c32a5c19944d9ae92d088e920d52fd29b16d45f6ba49c12b49d050e3dc94
|