html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<!-- ************************************* -->
<!-- *** README: Example on how to *** -->
<!-- *** alert on button click. *** -->
<!-- *** The python scripting occurs *** -->
<!-- *** between lines 16-19. *** -->
<!-- ************************************* -->
<html>
<head>
<title>Python in Browser</title>
<script text="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.7.3/brython.js"></script>
</head>
<body onload="brython()">
<button id="button0">Click me to display the alert</button>
<script type="text/python">
from browser import document, alert
def hello(ev):
alert("Hello World!")
document ["button0"].bind("click", hello)
</script>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run