-
Notifications
You must be signed in to change notification settings - Fork 8
Support for Pyodide and PyScript #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Vipitis
wants to merge
73
commits into
pygfx:main
Choose a base branch
from
Vipitis:browser
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 64 commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
c81ab50
js bitmap context
Vipitis 393b590
might need a loop -.-
Vipitis f0f533d
working loop
Vipitis d62dc39
assing js_array directly
Vipitis 93e3639
add context class
Vipitis bd9b3ab
fix channels
Vipitis 9017288
register auto backend
Vipitis a10970d
working events!
Vipitis e62274a
fix pixel order
Vipitis d79656c
cleanup testing code
Vipitis 8d51188
remove unused context class
Vipitis 1044d0f
add all events
Vipitis d393c52
add basic documentation
Vipitis 8b71ed7
typos pass
Vipitis f197d7d
embed examples into docs
Vipitis 529c3ec
maybe fix wheel location
Vipitis 7025f87
maybe fix files
Vipitis 58bc775
add canvas selector
Vipitis 51459d3
add multicanvas example
Vipitis 6cf0ba5
use asyncio loop
Vipitis d9f8fc0
ruff format
Vipitis fcd2d1c
add canvas element arg
Vipitis 3e13446
simplify selector argument
Vipitis 75e3ddc
icorrect type hints
Vipitis 879399e
enbled wgpu context
Vipitis 7544b77
fix button ids in pointer events
Vipitis 2dd4824
add resize event
Vipitis 053f2db
make the example resize
Vipitis ef8d9d3
fix pointer_move just inside or down
Vipitis 475943c
some comments and VSCode formatting html
almarklein c2b3aa7
Merge branch 'main' into browser
almarklein 485088a
script to serve examples
almarklein 2584ecb
Add simple multi-canvas pyodide example
almarklein dd8545f
Check incoming canvas element, and use getElementById
almarklein 740993a
make variable private
almarklein 05d5b6e
Add pyscript example
almarklein 69d2381
Add pyscript example
almarklein c2a313f
Flesh out the drawing mechanism
almarklein a338395
Merge branch 'main' into browser
almarklein 041082a
Properly implement resizing
almarklein 21da505
prevent canvas becoming infinitely large
almarklein da6ea72
Even better presentation, avoiding async
almarklein d8140a5
Allow right-click (prevent context menu)
almarklein 643263a
implement close set_cursor, set_title
almarklein 6edf5ec
use wrappers for adding handlers
almarklein 11c6e68
Tweak all events. Only char does not work on chrome
almarklein 1687744
Fix char event on chrome
almarklein 28bf576
The js context is an implementation detail
almarklein 0c881a2
rename server script
almarklein aa0f4cf
Remove old examples; their code ended up in other examples
almarklein 24b353b
doc-build also builds wheel
almarklein cba8479
Add pyodide examples to docs without changing py source
almarklein 34e4a35
clean
almarklein 0af1ad0
add build to doc and example deps
almarklein 702a0a4
add tests for html backend
almarklein b4f6d00
Fixes for setting size
almarklein 2f85d5c
Merge branch 'main' into browser
almarklein 27f45aa
Use flit to build wheels
almarklein 03ca0c0
fix sphinx, i think
almarklein fc5d5da
Rename html backend -> pyodide backend
almarklein 9826904
Fix that pointer up event did not always receive the right button
almarklein 677db3c
more tweaks and fix docs
almarklein bd01cd9
Various tweaks
almarklein f3bfaf0
enable future wgpu support
almarklein 464d314
Apply suggestions from code review
almarklein 551cc50
fix dragging
almarklein 8d39bc0
More review suggestions
almarklein eddaf54
default canvas id = 'canvas'
almarklein baf518f
show py docstrings in pyscript pages
almarklein 4504f7c
Add back-to-list link in html exmaples
almarklein b06a8a1
use nearest neighbour
almarklein 3bcbdde
Make sure 480 height fits for examples in docs
almarklein 8f5f72b
Hopefully prevent popping up keyboard on mobile
almarklein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <!doctype html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
| <title>Rendercanvas example.py in Pyodide</title> | ||
| <script src="https://cdn.jsdelivr.net/pyodide/v0.29.0/full/pyodide.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <dialog id="loading" style='outline: none; border: none; background: transparent;'> | ||
| <h1>Loading...</h1> | ||
| </dialog> | ||
| <canvas id='rendercanvas' style='width:calc(100% - 20px); height: 450px; background-color: #ddd;'></canvas> | ||
| <script type="text/javascript"> | ||
| async function main() { | ||
| let loading = document.getElementById('loading'); | ||
| loading.showModal(); | ||
| try { | ||
| let example_name = document.location.hash.slice(1); | ||
| pythonCode = await (await fetch(example_name)).text(); | ||
| let pyodide = await loadPyodide(); | ||
| await pyodide.loadPackage("micropip"); | ||
| const micropip = pyodide.pyimport("micropip"); | ||
| await micropip.install('sniffio'); | ||
| await micropip.install('numpy'); | ||
| // The below loads rendercanvas from pypi. But we will replace it with the name of the wheel, | ||
| // so that it's loaded from the docs (in _static). | ||
| await micropip.install("rendercanvas"); | ||
| // Run the Python code async because some calls are async it seems. | ||
| pyodide.runPythonAsync(pythonCode); | ||
| loading.close(); | ||
| } catch (err) { | ||
| loading.innerHTML = "Failed to load: " + err; | ||
| } | ||
| } | ||
| main(); | ||
| </script> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,10 @@ | ||
| div.sphx-glr-download, | ||
| div.sphx-glr-download-link-note { | ||
| display: none; | ||
| } | ||
|
|
||
| div.document iframe { | ||
| width: 100%; | ||
| height: 500px; | ||
| border: none; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.