This repository was archived by the owner on Jun 7, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 223
Brython as a Python 3 interpreter for activecode for advanced exercises #1208
Open
AngelaRemolina
wants to merge
10
commits into
RunestoneInteractive:master
Choose a base branch
from
AngelaRemolina:brython-activecode
base: master
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 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c0ae589
Add the html elements needed for brython
AngelaRemolina e418f65
Work-in-progress python3_interpreter activecode directive
AngelaRemolina 82d391d
'python3_interpreter' activecode directive for brython
AngelaRemolina 1725fe7
Merge pull request #4 from angelasofiaremolinagutierrez/brython-activ…
AngelaRemolina a88e6aa
Merge branch 'master' into brython-activecode
AngelaRemolina a7d1ae6
Concat using ${prog} instead of +prog+
AngelaRemolina b91d262
Resolve conflicts with package-lock.json
AngelaRemolina bd84eff
Merge branch 'master' into brython-activecode
AngelaRemolina 671a63d
Correcting indentation mistake
AngelaRemolina 82a2822
Add console to show errors and print()
AngelaRemolina 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,63 @@ | ||
| import { ActiveCode } from "./activecode.js"; | ||
|
|
||
| export default class BrythonActiveCode extends ActiveCode { | ||
| constructor(opts) { | ||
| super(opts); | ||
| opts.alignVertical = true; | ||
| this.python3_interpreter = $(orig).data("python3_interpreter"); | ||
| $(this.runButton).text("Render"); | ||
| this.editor.setValue(this.code); | ||
| } | ||
|
|
||
| async runProg() { | ||
| var prog = await this.buildProg(true); | ||
| let saveCode = "True"; | ||
| this.saveCode = await this.manage_scrubber(saveCode); | ||
| $(this.output).text(""); | ||
| if (!this.alignVertical) { | ||
| $(this.codeDiv).switchClass("col-md-12", "col-md-6", { | ||
| duration: 500, | ||
| queue: false, | ||
| }); | ||
| } | ||
| $(this.outDiv).show({ duration: 700, queue: false }); | ||
| prog = ` | ||
| <html> | ||
| <head> | ||
| <script type='text/javascript' src='https://cdn.jsdelivr.net/npm/[email protected]/brython.min.js'></script> | ||
| </head> | ||
| <body onload='brython()'> | ||
| <script type='text/python'>` + prog + | ||
| ` | ||
| </script> | ||
| </body> | ||
| </html> | ||
| `; | ||
| this.output.srcdoc = prog; | ||
| } | ||
|
|
||
| createOutput() { | ||
| this.alignVertical = true; | ||
| var outDiv = document.createElement("div"); | ||
| $(outDiv).addClass("ac_output"); | ||
| if (this.alignVertical) { | ||
| $(outDiv).addClass("col-md-12"); | ||
| } else { | ||
| $(outDiv).addClass("col-md-5"); | ||
| } | ||
| this.outDiv = outDiv; | ||
| this.output = document.createElement("iframe"); | ||
| $(this.output).css("background-color", "white"); | ||
| $(this.output).css("position", "relative"); | ||
| $(this.output).css("height", "400px"); | ||
| $(this.output).css("width", "100%"); | ||
| outDiv.appendChild(this.output); | ||
| this.outerDiv.appendChild(outDiv); | ||
| var clearDiv = document.createElement("div"); | ||
| $(clearDiv).css("clear", "both"); // needed to make parent div resize properly | ||
| this.outerDiv.appendChild(clearDiv); | ||
| } | ||
| enableSaveLoad() { | ||
| $(this.runButton).text($.i18n("msg_activecode_render")); | ||
| } | ||
| } | ||
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
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.