Created
November 14, 2022 15:47
-
-
Save jsbueno/07c34a93b64f35e00ea3fbd091d5a093 to your computer and use it in GitHub Desktop.
brython "hello world" showing the easy-to use DOM integration that is lacking on other python-on-browsers.
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script type="text/javascript" src="brython.js"></script> | |
<script type="text/javascript" src="brython_stdlib.js"></script> | |
</head> | |
<body onload="brython(1)"> | |
<div id="main"></div> | |
<script type="text/python"> | |
from browser import document | |
from browser.timer import set_timeout | |
import random | |
counter = 0 | |
def muda(): | |
global counter | |
colors = "yellow blue red green".split() | |
document["main"].style["color"] = random.choice(colors) | |
document["main"].innerHTML = str(counter) | |
counter += 1 | |
set_timeout(muda, 200) | |
muda() | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment