Questions tagged [brython]

Brython is a browser-integrated Python engine.

Brython stands for Browser's Python. It's goal is to replace JavaScript with Python as the scripting language for web browsers. It is composed of a lightweight run-time translation layer that brings many of Python's syntax niceties directly to the browser, as simple as using a <script type="text/python"> tag.

Some possible uses are

  • Creating simple document elements,
  • Drag and drop elements
  • 3D navigation
  • Geolocation
  • Charts and graphs

For more examples visit the home page and refer to the gallery.

Brython is open source and the source code is available here. Documentation can be found at http://www.brython.info/doc/en/index.html.

108 questions
0
votes
1 answer

Brython: how to include svg image?

I am trying to include and already existing svg image at a given position on the small webpage that I am designing, and since I am a total javascript noob I decided to use Brython. I thought the following command triangle =…
Johncowk
  • 342
  • 1
  • 16
0
votes
1 answer

Redirect after Ajax post not redirecting

Yes, I know this is similar to other questions, but the Brython syntax and functions are so much different that their solutions aren't applicable here. After doing a successful post with Ajax, the webpage is not redirecting to what Flask tells it…
0
votes
0 answers

Errors when trying to view Ajax post methods using Flask

I trying using Brython with Ajax imported to test ajax.post. When I do, I get the error "TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement." in my server console and…
0
votes
0 answers

Python skips over the first if condition whenever adding these two specific lines of code

When looking at lines 54-59, there are two lines of code that state: hero_health -= ENEMY_DAMAGE_AMOUNT enemy_health -= HERO_DAMAGE_AMOUNT[damage_choice] Whenever I add these lines of code to the if statement, the program just completely skips…
0
votes
1 answer

Brython wait for image to load, ajax call, or other async functions to complete before continuing execution

How can Brython wait for an image to load similarly to how Jquery/Javascript does before proceeding with execution? In the above Brython code errors list is never appended to because img.bind('load', on_load) does not block execution. How can I…
Pyramid Power
  • 35
  • 1
  • 6
0
votes
1 answer

How to import a class using brython?

In recent day I've doing a mini-project (Conway's Game of Life) with python. I want to do the GUI for the browser, so I decided to use a library called brython, that allow me to use python in the client side (is an interpreter, transforming python…
0
votes
1 answer

Run python from HTML

I need to run some python code when HTML button click, I try this code but when I clicked the button nothing happened. This is my code: '''