-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe05_login_box.py
74 lines (55 loc) · 1.28 KB
/
e05_login_box.py
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
64
65
66
67
68
69
70
71
72
73
74
import marimo
__generated_with = "0.9.0"
app = marimo.App(width="medium")
@app.cell(hide_code=True)
def __(mo):
login_box = mo.md("""
- Username: {name}
- Password: {pswd}
""").batch(
name=mo.ui.text(placeholder="用户名"),
pswd=mo.ui.text(kind="password")
).form()
login_box
return (login_box,)
@app.cell
def __(login_box):
login_box.value
return
@app.cell
def __(check_login, login_box):
check_login(**login_box.value)
return
@app.cell
def __(ACCOUNT, mo):
def check_login(name, pswd):
if name in ACCOUNT and pswd == ACCOUNT[name]:
mo.status.toast("登录成功!")
return True
mo.status.toast("用户名或密码错误!", kind="danger")
return False
return (check_login,)
@app.cell
def __():
return
@app.cell
def __():
ACCOUNT = {
"guest": "guest",
"root": "123456",
}
return (ACCOUNT,)
@app.cell
def __():
import marimo as mo
return (mo,)
@app.cell
def __(mo):
mo.accordion({
"版权声明": f"""
本项目代码及其实例均遵循开源协议,更多实例请访问:[项目主页](https://github.com/switchball/100-marimo-projects)。
""",
})
return
if __name__ == "__main__":
app.run()