-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
63 lines (51 loc) · 1.6 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.7.5/brython.min.js">
</script>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.7.5/brython_stdlib.js">
</script>
<script src="widgets.brython.js"></script>
<link rel="stylesheet" href="brython-widgets.css">
</script>
</head>
<body onload="brython(1)">
<script type="text/python">
from browser import bind, document, html
import dialog, menu
menubar = menu.Menu(document["menubar"])
file_menu = menubar.add_menu("File")
new_menu = file_menu.add_menu("New")
new_menu.add_item("Python")
new_menu.add_item("Javascript")
@file_menu.add_item("Open...")
def open_file(evt):
entry = dialog.EntryDialog("Open file", "File name")
@bind(entry, "entry")
def handle(evt):
entry.remove()
dialog.InfoDialog("Widgets test", entry.value)
edit_menu = menubar.add_menu("Edition")
edit_menu.add_item("Search")
edit_menu.add_item("Select all")
menubar.add_item("Coucou")
save_menu = file_menu.add_menu("Save")
save_menu.add_item("text")
save_menu.add_item("json")
# dialog
themes = ["Sunrise", "Day", "Evening", "Sunset", "Night"]
themes_dialog = dialog.Dialog("Widgets test", ok_cancel=True)
selector = html.SELECT(html.OPTION(theme) for theme in themes)
themes_dialog.panel <= selector
@bind(selector, "change")
def choose_theme(evt):
chosen = selector.options[selector.selectedIndex].value
themes_dialog.remove()
dialog.InfoDialog("Widgets test",f"Selected: {chosen}")
</script>
<div id="menubar"></div>
</body>
</html>