Skip to main content

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と同じです。

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)

Source distribution for pyxelmagic 1.1.1
File Size Uploaded
pyxelmagic-1.1.1.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyxelmagic 1.1.1
File Interpreter ABI Platform
pyxelmagic-1.1.1-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page