fish 1 year ago
parent
commit
64a155c52a

+ 0 - 0
.env → demo/.env


+ 9 - 0
demo/app/__init__.py

@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 19:31:33
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   
+'''
+from .app import App

+ 120 - 0
demo/app/app.py

@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 19:12:38
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   
+'''
+
+import flet as ft
+from flet import (
+    Checkbox,
+    Column,
+    FloatingActionButton,
+    IconButton,
+    OutlinedButton,
+    Page,
+    Row,
+    Tab,
+    Tabs,
+    Text,
+    TextField,
+    UserControl,
+    colors,
+    icons,
+)
+from flet.plotly_chart import PlotlyChart
+import logging
+
+from .pages.home import HomePage
+from .pages.plotly_chart import ChartPage
+from .pages.todo import TodoPage
+
+class App(UserControl):
+    ''' build a flet app '''
+
+    def __init__(self):
+        ''' init '''
+        super().__init__()
+        log_format = "%(asctime)s - %(levelname)s - %(message)s"
+        logging.basicConfig(filename='app.log', level=logging.DEBUG, format=log_format)
+        logging.info('程序启动')
+
+    @staticmethod
+    def main(page: ft.Page):
+        ''' main page '''
+        # page.title = "ToDo App"
+        # page.horizontal_alignment = "center"
+        # page.scroll = "adaptive"
+        # page.update()
+        # page.add(app)
+
+        content = HomePage()
+        def menu_changed(e):
+            ''' menu change evnet '''
+            content.controls.clear()
+            if e.control.selected_index == 0:
+                content.controls.append(HomePage())
+            elif e.control.selected_index == 1:
+                content.controls.append(TodoPage())
+            elif e.control.selected_index == 2:
+                content.controls.append(ft.Text("商品库!"))
+            elif e.control.selected_index == 3:
+                fig = ChartPage().DrawChart()
+                # fig.show()
+                content.controls.append(PlotlyChart(fig, expand=True))
+            elif e.control.selected_index == 4:
+                content.controls.append(ft.Text("Setting!"))
+            page.update()
+
+        rail = ft.NavigationRail(
+            selected_index=0,
+            label_type=ft.NavigationRailLabelType.ALL,
+            # extended=True,
+            min_width=100,
+            min_extended_width=400,
+            # leading=ft.FloatingActionButton(icon=ft.icons.CREATE, text="Add"),
+            group_alignment=-0.9,
+            destinations=[
+                ft.NavigationRailDestination(
+                    icon=ft.icons.HOME, selected_icon=ft.icons.HOME, label="首页"
+                ),
+                ft.NavigationRailDestination(
+                    icon_content=ft.Icon(ft.icons.FAVORITE),
+                    selected_icon_content=ft.Icon(name=ft.icons.FAVORITE, color=ft.colors.PINK),
+                    label="关键词",
+                ),
+                ft.NavigationRailDestination(
+                    icon_content=ft.Icon(ft.icons.SHOPIFY),
+                    selected_icon_content=ft.Icon(name=ft.icons.SHOPIFY, color=ft.colors.PINK),
+                    label="商品库",
+                ),
+                ft.NavigationRailDestination(
+                    icon_content=ft.Icon(ft.icons.BAR_CHART),
+                    selected_icon_content=ft.Icon(name=ft.icons.BAR_CHART, color=ft.colors.PINK),
+                    label="数据分析",
+                ),
+                ft.NavigationRailDestination(
+                    icon=ft.icons.SETTINGS_OUTLINED,
+                    selected_icon_content=ft.Icon(ft.icons.SETTINGS),
+                    label_content=ft.Text("Settings"),
+                ),
+            ],
+            on_change=menu_changed,
+        )
+        page.title = 'First App'
+        page.add(
+            ft.Row(
+                [
+                    rail,
+                    ft.VerticalDivider(width=1),
+                    content,
+                ],
+                expand=True,
+            )
+        )
+
+    def run(self):
+        ''''''
+        ft.app(target=self.main, view=ft.WEB_BROWSER, host="0.0.0.0", port=8080)

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

@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 20:14:34
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   model
+'''
+
+from .user import UserModel
+
+
+

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

@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 20:25:06
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   
+'''
+
+from .home import HomePage
+from .plotly_chart import ChartPage
+from .todo import TodoPage
+

+ 5 - 1
demo/app/pages/home.py

@@ -19,4 +19,8 @@ class HomePage(Column):
         super().__init__()
         super().__init__()
         self.controls.clear()
         self.controls.clear()
         self.controls.append(Column([Text("Body!")], alignment=MainAxisAlignment.START, expand=True))
         self.controls.append(Column([Text("Body!")], alignment=MainAxisAlignment.START, expand=True))
-    
+
+class Banner(Column):
+
+    def __init__(self):
+        pass

+ 2 - 2
demo/app/pages/plotly_chart.py

@@ -9,10 +9,10 @@ from flet.matplotlib_chart import MatplotlibChart
 matplotlib.use("svg")
 matplotlib.use("svg")
 
 
 class ChartPage():
 class ChartPage():
-    ''''''
+    '''chart page '''
     
     
     def DrawChart(self):
     def DrawChart(self):
-        ''''''
+        ''' draw chart '''
         x = ['day 1', 'day 1', 'day 1', 'day 1', 'day 1', 'day 1',
         x = ['day 1', 'day 1', 'day 1', 'day 1', 'day 1', 'day 1',
              'day 2', 'day 2', 'day 2', 'day 2', 'day 2', 'day 2']
              'day 2', 'day 2', 'day 2', 'day 2', 'day 2', 'day 2']
 
 

+ 19 - 0
demo/app/pages/setting.py

@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 20:31:43
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   
+'''
+
+import flet as ft
+from flet_core import Column, MainAxisAlignment
+from flet import UserControl
+
+class Setting(UserControl):
+    ''' setting page '''
+
+    def __init__(self):
+        pass
+    

+ 1 - 0
demo/app/pages/todo.py

@@ -3,6 +3,7 @@ from flet_core import Column, MainAxisAlignment
 
 
 
 
 class TodoPage(Column):
 class TodoPage(Column):
+    ''' todo page '''
 
 
     def add_clicked(self, e):
     def add_clicked(self, e):
         if self.new_task.value:
         if self.new_task.value:

+ 4 - 105
demo/main.py

@@ -7,109 +7,8 @@
 @Desc    :   ente point
 @Desc    :   ente point
 '''
 '''
 
 
-import logging
+from app import App
 
 
-import flet as ft
-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 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()
-        if e.control.selected_index == 0:
-            content.controls.append(HomePage())
-        elif e.control.selected_index == 1:
-            content.controls.append(TodoPage())
-        elif e.control.selected_index == 2:
-            content.controls.append(ft.Text("商品库!"))
-        elif e.control.selected_index == 3:
-            fig = ChartPage().DrawChart()
-            # fig.show()
-            content.controls.append(PlotlyChart(fig, expand=True))
-        elif e.control.selected_index == 4:
-            content.controls.append(ft.Text("Setting!"))
-        page.update()
-
-    rail = ft.NavigationRail(
-        selected_index=0,
-        label_type=ft.NavigationRailLabelType.ALL,
-        # extended=True,
-        min_width=100,
-        min_extended_width=400,
-        # leading=ft.FloatingActionButton(icon=ft.icons.CREATE, text="Add"),
-        group_alignment=-0.9,
-        destinations=[
-            ft.NavigationRailDestination(
-                icon=ft.icons.HOME, selected_icon=ft.icons.HOME, label="首页"
-            ),
-            ft.NavigationRailDestination(
-                icon_content=ft.Icon(ft.icons.FAVORITE),
-                selected_icon_content=ft.Icon(name=ft.icons.FAVORITE, color=ft.colors.PINK),
-                label="关键词",
-            ),
-            ft.NavigationRailDestination(
-                icon_content=ft.Icon(ft.icons.SHOPIFY),
-                selected_icon_content=ft.Icon(name=ft.icons.SHOPIFY, color=ft.colors.PINK),
-                label="商品库",
-            ),
-            ft.NavigationRailDestination(
-                icon_content=ft.Icon(ft.icons.BAR_CHART),
-                selected_icon_content=ft.Icon(name=ft.icons.BAR_CHART, color=ft.colors.PINK),
-                label="数据分析",
-            ),
-            ft.NavigationRailDestination(
-                icon=ft.icons.SETTINGS_OUTLINED,
-                selected_icon_content=ft.Icon(ft.icons.SETTINGS),
-                label_content=ft.Text("Settings"),
-            ),
-        ],
-        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(
-            [
-                rail,
-                ft.VerticalDivider(width=1),
-                content,
-            ],
-            expand=True,
-        )
-    )
-ft.app(target=main, view=ft.WEB_BROWSER)
+if __name__=='__main__':
+    app = App()
+    app.run()

+ 3 - 3
demo/setup.py

@@ -10,9 +10,9 @@ build_exe_options = {
 }
 }
 
 
 setup(
 setup(
-    name="电商大数据工具",
-    version="1.0",
-    description="电商大数据工具",
+    name="demo",
+    version="1.0.1",
+    description="demo desc",
     options={
     options={
         "build_exe": build_exe_options
         "build_exe": build_exe_options
     },
     },