-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (34 loc) · 1.13 KB
/
Copy pathmain.py
File metadata and controls
47 lines (34 loc) · 1.13 KB
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
import flet as ft
from repath import match
from views import MainView, BookView
def main(page: ft.Page):
page.title = "Library Manager"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
# page.client_storage.clear()
page.window_width = 900
page.window_max_width = 900
page.window_min_width = 900
page.window_height = 600
page.window_max_height = 600
page.window_min_height = 600
page.window_maximizable = False
page.padding = 0
def route_change(route: ft.RouteChangeEvent):
page.views.clear()
router = ft.TemplateRoute(page.route)
if route.data == "/main":
page.views.append(
MainView(page=page, route="/main")
)
if router.match("/book/:uuid"):
book_info = list(filter(lambda b: b['uuid'] == router.uuid, page.client_storage.get("books")))[0]
page.views.append(
BookView(page=page, route="/book", book_info=book_info)
)
page.update()
page.on_route_change = route_change
page.go("/main")
if __name__ == "__main__":
ft.app(
target=main
)