Browse Source

项目结构优化

fish 1 year ago
parent
commit
731f4c38b8

+ 0 - 0
.env


+ 0 - 0
demo/app/__init__.py


+ 0 - 0
demo/app/model/__init__.py


+ 4 - 0
demo/app/model/user.py

@@ -0,0 +1,4 @@
+class UserModel(object):
+    
+    def __init__(self):
+        pass

+ 0 - 0
demo/app/pages/__init__.py


+ 12 - 2
demo/Home.py → demo/app/pages/home.py

@@ -1,11 +1,21 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 10:11:57
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   home page
+'''
+
 from flet_core import UserControl, Column, Row, FloatingActionButton, icons, TextField, Tabs, Tab, Text, \
     MainAxisAlignment
 
 
 class HomePage(Column):
-    ''''''
+    '''home page'''
+    
     def __init__(self):
-        ''''''
+        ''' init '''
         super().__init__()
         self.controls.clear()
         self.controls.append(Column([Text("Body!")], alignment=MainAxisAlignment.START, expand=True))

+ 0 - 0
demo/PlotlyChart.py → demo/app/pages/plotly_chart.py


+ 0 - 0
demo/Todo.py → demo/app/pages/todo.py


+ 0 - 0
demo/app/utils/__init__.py


+ 9 - 0
demo/app/utils/str_util.py

@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 11:13:50
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   str util
+'''
+

+ 40 - 8
demo/main.py

@@ -1,26 +1,53 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 10:11:11
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   ente point
+'''
+
 import logging
 
 import flet as ft
-from Home import HomePage
-from Todo import TodoPage
+from app.pages.home import HomePage
+from app.pages.todo import TodoPage
+from app.pages.plotly_chart import ChartPage
+
 import plotly.graph_objects as go
 from flet.plotly_chart import PlotlyChart
 
-from PlotlyChart import ChartPage
-
+from flet import AppBar
+from flet import Card
+from flet import Column
+from flet import Container
+from flet import ElevatedButton
+from flet import IconButton
+from flet import NavigationRail
+from flet import NavigationRailDestination
+from flet import Page
+from flet import Row
+from flet import Stack
+from flet import Switch
+from flet import Text
+from flet import VerticalDivider
+from flet import colors
+from flet import icons
+from flet.utils import slugify
 
 def main(page: ft.Page):
+    ''' main  '''
     log_format = "%(asctime)s - %(levelname)s - %(message)s"
     logging.basicConfig(filename='app.log', level=logging.DEBUG, format=log_format)
     logging.info('程序启动')
+
     content = HomePage()
     def menu_changed(e):
+        ''' menu change evnet '''
         content.controls.clear()
-        print("Selected destination:", e.control.selected_index)
         if e.control.selected_index == 0:
             content.controls.append(HomePage())
         elif e.control.selected_index == 1:
-            # content.controls.append(ft.Text("One!"))
             content.controls.append(TodoPage())
         elif e.control.selected_index == 2:
             content.controls.append(ft.Text("商品库!"))
@@ -68,6 +95,12 @@ def main(page: ft.Page):
         on_change=menu_changed,
     )
     page.title = 'First App'
+    # menu_button = IconButton(icons.MENU)
+    # page.appbar = AppBar(
+    #     leading=menu_button,
+    #     leading_width=40,
+    #     bgcolor=colors.SURFACE_VARIANT,
+    # )
 
     page.add(
         ft.Row(
@@ -79,5 +112,4 @@ def main(page: ft.Page):
             expand=True,
         )
     )
-
-ft.app(target=main)
+ft.app(target=main, view=ft.WEB_BROWSER)

+ 2 - 1
demo/requirements.txt

@@ -1,8 +1,9 @@
 flet
 plotly
 pandas
+kaleido
 matplotlib
-
+python-dotenv