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
74
votes
13 answers

How can I integrate Python and JavaScript?

Is it possible to integrate Python and JavaScript? For example, imagine you wanted to be able to define classes in JavaScript and use them from Python (or vice versa). If so, what's the best way? I'm interested not only if this is possible but if…
Jacob Gabrielson
  • 34,800
  • 15
  • 46
  • 64
17
votes
4 answers

Is Brython entirely client-side?

I have a piece of code written in Python. I would like to put that code in a webpage. Brython seems like the simplest way to glue the two things together, but I don't have a server that can actually run code on the server side. Does Brython require…
badp
  • 11,409
  • 3
  • 61
  • 89
13
votes
3 answers

Is it possible to run native python code in chrome?

I was wondering if it is possible to run native python code in chrome instead of javascript. I have seen projects like pyjs or brython, but what they do is compile python to javascript. While those are great projects a problem with this approach is…
m3o
  • 3,881
  • 3
  • 35
  • 56
8
votes
3 answers

How to compile Python with Brython to Javascript (to run with nodejs)?

How can I use Brython to compile Python to Javascript? I want to do this on my computer, so I can the run Javascript with nodejs, eg. $ python hello.py Hello world $ brython hello.py -o hello.js $ node hello.js Hello world The examples on the…
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
7
votes
2 answers

How to use ajax in Brython

I am writing a web application using Flask and would like to use browser.ajax functionality in Brython but couldn't find a workable example. It would be very nice if someone demonstrates a short example how to use ajax in Brython. More specifically,…
chemist
  • 373
  • 9
  • 20
6
votes
1 answer

Two scripts conflicting in the HTML head (Brython & iFlyChat)

I'm loading Brython and iFlyChat but Brython won't work if the iFlyChat script is uncommented. I've tried all sorts of async combinations but there seems to be something more fundamental. JSFiddle here and code…
Jack
  • 313
  • 5
  • 22
6
votes
3 answers

How to import library using Brython

I wish to import my own library in Brython. This page of the documentation purports to show how, by adding the appropriate directory to the python path, but I can't make it work because I can't make Brython import sys. Here's the simplest example…
EddyTheB
  • 3,100
  • 4
  • 23
  • 32
4
votes
2 answers

How to bind text input to another div on the same html page

I've made a tag list that takes user input and binds it to another input field as a list of tags. However, after weeks messing around with Javascript and JQuery the only way (and importantly an elegant way) I've been able to do it is using Brython.…
Jack
  • 313
  • 5
  • 22
4
votes
2 answers

Brython and Python

I've been playing around with Python for some days and I got to the point where I want to put the code of my Python application on the web. Basically the application is all about asking user a question and counting the score based on user's answers…
Karolina
  • 71
  • 6
4
votes
1 answer

How can I create a websocket JSObject in brython?

I'm trying to use Brython to run Python code in the browser, and to use websockets in that Python code. I have working JavaScript code that can connect to the Websocket echo server at http://www.websocket.org/echo.html. According to the…
Paul
  • 3,634
  • 1
  • 18
  • 23
3
votes
0 answers

Using Brython with React

I’ve just started using Brython, and am able to receive input from the page and run it through a series of python functions to return a value - but I’m unsure of the correct way to pass these values into a react component. I know nothing about…
Numpy
  • 131
  • 2
3
votes
2 answers

Should super().__str__() in Brython return something different?

I ran across a weird situation using Brython and inheritance with the str method. Here's my test using the Brython console: >>> class A(object): ... def __str__(self): ... return "A __str__ output." ... >>> class B(A): ... def…
Kyle
  • 554
  • 3
  • 10
3
votes
0 answers

How to find all the cookies and header fields using a Brython script

How can we find all the cookies and header fields of a HTML document using a Brython script? I need to find a CSRF_TOKEN from the cookies, I've an alternative way of finding this token but then I have to mention my brython script in HTML, which I…
Vivek Singh
  • 346
  • 3
  • 14
3
votes
1 answer

Python/Brython TypeError: Cannot use cached_property instance without calling __set_name__ on it

I'm a network engineer, new to programming, so if I leave out any details do let me know. Trying my best to explain the problem here :) Getting a solution to this problem is very important for me, so any inputs would be highly appreciated. Problem…
Vivek Singh
  • 346
  • 3
  • 14
3
votes
1 answer

How to work with OpenCV python library using brython

I have a fully functional Python project which have been tested directly through the terminal. But when I searched on how to integrate Python code with a JavaScript wrapper, I found few of the open-source API's…
1
2 3 4 5 6 7 8