start build test
This commit is contained in:
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),
|
||||
}
|
||||
Reference in New Issue
Block a user