start build test
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.venv/
|
||||||
|
app/__pycache__/
|
||||||
|
app/pages/__pycache__/
|
||||||
|
app/build/
|
||||||
|
app/dist/
|
||||||
1
.python-version
Normal file
1
.python-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.12
|
||||||
62
app/designer.py
Normal file
62
app/designer.py
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import flet as ft
|
||||||
|
from flet.core.types import OptionalControlEventCallable
|
||||||
|
|
||||||
|
colors=[
|
||||||
|
"#E1B07E",#0
|
||||||
|
"#E5BE9E",#1
|
||||||
|
"#CBC0AD",#2
|
||||||
|
"#86A397",#3
|
||||||
|
"#361D2E"#4
|
||||||
|
]
|
||||||
|
|
||||||
|
class Conteiner(ft.Container):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TextField(ft.TextField):
|
||||||
|
def __init__(self, expand: bool = False, width:int=50, height:int = 50, read_only:bool=False):
|
||||||
|
if expand == False:
|
||||||
|
super().__init__(
|
||||||
|
expand=False,
|
||||||
|
width=width,
|
||||||
|
height=height,
|
||||||
|
read_only=read_only,
|
||||||
|
#bgcolor=colors[1],
|
||||||
|
cursor_color=colors[4],
|
||||||
|
#focus_color=colors[2],
|
||||||
|
focused_border_color=colors[2],
|
||||||
|
border_color=colors[4],
|
||||||
|
text_style=ft.TextStyle(
|
||||||
|
color=colors[0]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
super().__init__(
|
||||||
|
expand=True,
|
||||||
|
height=height,
|
||||||
|
read_only=read_only,
|
||||||
|
#bgcolor=colors[1],
|
||||||
|
cursor_color=colors[4],
|
||||||
|
#focus_color=colors[2],
|
||||||
|
focused_border_color=colors[2],
|
||||||
|
border_color=colors[4],
|
||||||
|
text_style=ft.TextStyle(
|
||||||
|
color=colors[0]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
class Button(ft.CupertinoFilledButton):
|
||||||
|
def __init__(self, on_click:OptionalControlEventCallable=None, text:str="load", height:int=50, width:int=100, alignment:ft.alignment=ft.alignment.center):
|
||||||
|
|
||||||
|
|
||||||
|
super().__init__(
|
||||||
|
on_click=on_click,
|
||||||
|
text=text,
|
||||||
|
focus_color=colors[4],
|
||||||
|
icon_color=colors[1],
|
||||||
|
alignment=alignment,
|
||||||
|
)
|
||||||
|
pass
|
||||||
16
app/main.py
Normal file
16
app/main.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import flet as ft
|
||||||
|
from view import ViewsHendler
|
||||||
|
|
||||||
|
|
||||||
|
def main(page: ft.Page):
|
||||||
|
page.title = "COPP"
|
||||||
|
def PageLoading(route={}):
|
||||||
|
print(page.route)
|
||||||
|
page.views.clear()
|
||||||
|
page.views.append(ViewsHendler(page=page)[page.route])
|
||||||
|
page.update()
|
||||||
|
|
||||||
|
page.on_route_change = PageLoading
|
||||||
|
page.go("/main")
|
||||||
|
|
||||||
|
ft.app(main,assets_dir="assets", upload_dir="assets/uploads")
|
||||||
135
app/pages/Main.py
Normal file
135
app/pages/Main.py
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
import flet as ft
|
||||||
|
import designer as ds
|
||||||
|
|
||||||
|
main_loading=None
|
||||||
|
class Main_page(ft.View):
|
||||||
|
|
||||||
|
def __init__(self, page:ft.Page):
|
||||||
|
self.page=page
|
||||||
|
self.file_picker = ft.FilePicker(on_result=self.load_file)
|
||||||
|
self.directory_picker = ft.FilePicker(on_result=self.load_directory)
|
||||||
|
self.page.overlay.append(self.file_picker)
|
||||||
|
self.page.overlay.append(self.directory_picker)
|
||||||
|
|
||||||
|
self.selection_mode = ft.RadioGroup(
|
||||||
|
content=ft.Row([
|
||||||
|
ft.Radio(value="file", label="Выбрать файл"),
|
||||||
|
ft.Radio(value="directory", label="Выбрать папку")
|
||||||
|
]),
|
||||||
|
value="file",
|
||||||
|
on_change=self.on_mode_change
|
||||||
|
)
|
||||||
|
|
||||||
|
self.file_url=ds.TextField(
|
||||||
|
#width=380,
|
||||||
|
expand=True,
|
||||||
|
read_only=True
|
||||||
|
)
|
||||||
|
|
||||||
|
self.button_load = ds.Button(on_click=self.clic_button_file, text="Выбрать файл")
|
||||||
|
|
||||||
|
super().__init__(
|
||||||
|
route="/main",
|
||||||
|
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
|
||||||
|
vertical_alignment=ft.MainAxisAlignment.CENTER,
|
||||||
|
#expand=True,
|
||||||
|
scroll="auto",
|
||||||
|
controls=[
|
||||||
|
ft.Row(
|
||||||
|
controls=[
|
||||||
|
ft.Container(
|
||||||
|
border_radius=ft.border_radius.all(10),
|
||||||
|
bgcolor=ds.colors[4],
|
||||||
|
height=80,
|
||||||
|
expand=True,
|
||||||
|
content=ft.Text("file loading",color=ds.colors[0],size=30),
|
||||||
|
alignment=ft.alignment.center_left,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
expand=True,
|
||||||
|
height=100,
|
||||||
|
),
|
||||||
|
ft.Row(
|
||||||
|
expand=True,
|
||||||
|
height=500,
|
||||||
|
controls=[
|
||||||
|
ft.Container(#болшой контейнер
|
||||||
|
padding=10,
|
||||||
|
expand=True,
|
||||||
|
border_radius=ft.border_radius.all(10),
|
||||||
|
bgcolor=ds.colors[4],
|
||||||
|
content=ft.Column(
|
||||||
|
controls=[
|
||||||
|
ft.Column(
|
||||||
|
controls=[
|
||||||
|
ft.Container(#контенер с выбором режима
|
||||||
|
padding=10,
|
||||||
|
expand=True,
|
||||||
|
bgcolor=ds.colors[3],
|
||||||
|
border_radius=ft.border_radius.all(10),
|
||||||
|
content=self.selection_mode
|
||||||
|
),
|
||||||
|
ft.Container(#контенер с ссылкой на документ
|
||||||
|
padding=10,
|
||||||
|
expand=True,
|
||||||
|
#width=500,
|
||||||
|
bgcolor=ds.colors[3],
|
||||||
|
border_radius=ft.border_radius.all(10),
|
||||||
|
content=ft.Column(
|
||||||
|
controls=[
|
||||||
|
self.file_url,
|
||||||
|
ft.Container(
|
||||||
|
#width=380,
|
||||||
|
expand=True,
|
||||||
|
alignment=ft.alignment.center_right,
|
||||||
|
content=self.button_load
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
ft.Container(
|
||||||
|
height=100,
|
||||||
|
alignment=ft.alignment.center_right,
|
||||||
|
bgcolor=ds.colors[3],
|
||||||
|
border_radius=ft.border_radius.all(10)
|
||||||
|
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def on_mode_change(self, e):
|
||||||
|
"""Обработчик изменения режима выбора"""
|
||||||
|
if self.selection_mode.value == "file":
|
||||||
|
self.button_load.text = "Выбрать файл"
|
||||||
|
else:
|
||||||
|
self.button_load.text = "Выбрать папку"
|
||||||
|
self.page.update()
|
||||||
|
|
||||||
|
def clic_button_file(self,e):
|
||||||
|
if self.selection_mode.value == "file":
|
||||||
|
self.file_picker.pick_files(
|
||||||
|
allow_multiple=False,
|
||||||
|
allowed_extensions=["xlsx", "xls"]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.directory_picker.get_directory_path()
|
||||||
|
self.page.update()
|
||||||
|
|
||||||
|
def load_file(self,e:ft.FilePickerResultEvent):
|
||||||
|
if e.files is not None:
|
||||||
|
for f in e.files:
|
||||||
|
print(f"Выбранный файл: {f.path}")
|
||||||
|
self.file_url.value = f.path
|
||||||
|
self.page.update()
|
||||||
|
|
||||||
|
def load_directory(self,e:ft.FilePickerResultEvent):
|
||||||
|
if e.path is not None:
|
||||||
|
print(f"Выбранная папка: {e.path}")
|
||||||
|
self.file_url.value = e.path
|
||||||
|
self.page.update()
|
||||||
8
app/view.py
Normal file
8
app/view.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import flet as ft
|
||||||
|
from pages.Main import Main_page
|
||||||
|
|
||||||
|
|
||||||
|
def ViewsHendler(page:ft.Page):
|
||||||
|
return{
|
||||||
|
"/main":Main_page(page=page),
|
||||||
|
}
|
||||||
6
main.py
Normal file
6
main.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
def main():
|
||||||
|
print("Hello from test-server-xlsx!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
12
pyproject.toml
Normal file
12
pyproject.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[project]
|
||||||
|
name = "test-server-xlsx"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.12"
|
||||||
|
dependencies = [
|
||||||
|
"fastapi[all]>=0.116.1",
|
||||||
|
"flet[all]>=0.28.3",
|
||||||
|
"numpy>=2.3.3",
|
||||||
|
"openpyxl>=3.1.5",
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user