Skip to content
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

Brython as a Python 3 interpreter for activecode #489

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

its-ChaTTy
Copy link

@its-ChaTTy its-ChaTTy commented Jun 8, 2024

I created an optional argument for activecode blocks called python3_interpreter. It can be used writing something like this:

.. activecode::
:language: python3
:python3_interpreter: brython

print("You can see this print on the browser console")
from browser import document, alert, html
def hello(ev):
    alert("Hello world! I'm using Brython now")

document <= html.BUTTON("My button", id="button_alert")
document["button_alert"].bind("click", hello)

I am working on a project called PyZombis. PyZombis is an spanish course to learn how to code in Python and it is being built using Runestone. We had issues making some advance exercises of the course that involves:

  1. GUI/ MVC (buttons, textbox, images)
  2. APIs (Facebook, twitter, etc.)
  3. Databases (sqlite queries from python)

The third one might be solved using the [SQL activecode option (https://runestone.academy/runestone/books/published/instructorguide/ActiveCode/sql.html), but the first two could not be done with any of the Runestone's tool.

This PR gives a graphic alternative for runestone. The output shows an iframe in which you can append things with the browser module that Brython offers.

The inspiration for this has been taken from a previous PR in the depreciated runestone components, you can find it here: RunestoneInteractive/RunestoneComponents#1208

Here is a gif of how it works (on an exercises that works with the Facebook API showing public profile photos):
122336319-420d8a80-cf02-11eb-8afd-675f572ee565

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant