pyflutter-app 0.3.6__tar.gz → 0.3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/PKG-INFO +1 -1
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/config_app.py +24 -28
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/home_page/view.py +182 -143
- pyflutter_app-0.3.7/converter/page_image/__init__.py +4 -0
- pyflutter_app-0.3.7/converter/page_image/common.py +130 -0
- pyflutter_app-0.3.7/converter/page_image/controller_image.py +285 -0
- pyflutter_app-0.3.7/converter/page_image/model_image.py +95 -0
- pyflutter_app-0.3.7/converter/page_image/renderer.py +92 -0
- pyflutter_app-0.3.7/converter/page_image/view_image.py +188 -0
- pyflutter_app-0.3.7/converter/page_image/widgets.py +363 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/run_app_convert.py +11 -11
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/util.py +13 -17
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyproject.toml +1 -1
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/uv.lock +1 -1
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/.gitignore +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/.idea/.gitignore +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/.idea/inspectionProfiles/Project_Default.xml +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/.idea/misc.xml +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/.idea/modules.xml +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/.idea/pyflutter_app.iml +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/.idea/vcs.xml +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/README.md +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/cartas/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/cartas/origin.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/__main__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/assets/forms_config.json +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/home_page/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/home_page/_page_edit.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/home_page/controller.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/home_page/model.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/lib_toi.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/Diagnorstico.txt +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/common.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/config.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/controller_forms.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/diagnose_forms.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/master_forms.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/model_forms.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/service.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/page_forms/view_forms.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/table_widget.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/whatsapp/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/converter/whatsapp/model.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/local_build/linux.sh +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/local_build/send.sh +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/main.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/mvc/controller.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/mvc/model.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/mvc/view.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/new-export_app.sh +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/ocrlib/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pdflib/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/app.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/file_picker.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/navigator.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/scheduler.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/theme.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/ui/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/ui/buttons.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/ui/container.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/ui/core.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/ui/list_builder.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/ui/progress.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/ui/tables.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/pyflutter_ui/ui/widgets.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/table_stream/__init__.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/test_claude.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/teste_ocr.py +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/update.sh +0 -0
- {pyflutter_app-0.3.6 → pyflutter_app-0.3.7}/whatsapp_files/__init__.py +0 -0
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from dataclasses import dataclass
|
|
3
|
-
|
|
4
|
-
from table_stream.sysfiles import File, Directory, UserFileSystem, JsonConvert
|
|
5
|
-
from table_stream import HashMapDict
|
|
3
|
+
from table_stream import File, Directory, UserFileSystem, JsonConvert, HashMapDict
|
|
6
4
|
from pyflutter_ui.theme import ThemeMode
|
|
7
5
|
from pyflutter_ui.ui.core import ValueNotifier
|
|
8
6
|
|
|
9
7
|
|
|
10
8
|
@dataclass
|
|
11
9
|
class MapConfig:
|
|
12
|
-
|
|
13
|
-
initial_dir: Directory
|
|
10
|
+
|
|
11
|
+
initial_dir: Directory
|
|
14
12
|
last_dir: Directory
|
|
15
13
|
work_dir: Directory
|
|
16
14
|
documents_dir: Directory
|
|
17
15
|
theme_mode: ThemeMode
|
|
18
|
-
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
|
|
21
18
|
class FactoryMapConfig(object):
|
|
22
|
-
|
|
19
|
+
|
|
23
20
|
def __init__(self) -> None:
|
|
24
21
|
self._conf: MapConfig = MapConfig(
|
|
25
22
|
initial_dir=UserFileSystem().get_user_downloads(),
|
|
@@ -28,10 +25,10 @@ class FactoryMapConfig(object):
|
|
|
28
25
|
documents_dir=UserFileSystem().get_user_downloads().concat("RFA", True),
|
|
29
26
|
theme_mode=ThemeMode.DARK,
|
|
30
27
|
)
|
|
31
|
-
|
|
28
|
+
|
|
32
29
|
def create_default(self) -> MapConfig:
|
|
33
30
|
return self._conf
|
|
34
|
-
|
|
31
|
+
|
|
35
32
|
def create_from_dict(self, h: HashMapDict[str, str]) -> MapConfig:
|
|
36
33
|
if h.header().contains("initial_dir"):
|
|
37
34
|
self._conf.initial_dir = Directory(h["initial_dir"])
|
|
@@ -47,36 +44,36 @@ class FactoryMapConfig(object):
|
|
|
47
44
|
else:
|
|
48
45
|
self._conf.theme_mode = ThemeMode.SYSTEM
|
|
49
46
|
return self._conf
|
|
50
|
-
|
|
47
|
+
|
|
51
48
|
def create_from_file(self, file_json: File) -> MapConfig:
|
|
52
49
|
converter = JsonConvert.from_file(file_json)
|
|
53
50
|
map_data = converter.data.to_dict()
|
|
54
51
|
return self.create_from_dict(HashMapDict(map_data))
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
|
|
53
|
+
|
|
57
54
|
class AppConfigNotifier(ValueNotifier[MapConfig]):
|
|
58
|
-
|
|
55
|
+
|
|
59
56
|
file_config: File = UserFileSystem().cache_dir().join_file("RFA-config.json")
|
|
60
|
-
|
|
57
|
+
|
|
61
58
|
def __init__(self, value: MapConfig = FactoryMapConfig().create_default()) -> None:
|
|
62
59
|
super().__init__(value)
|
|
63
|
-
#self._file_config: File = self.value.work_dir.concat("config", True).join_file("app_config.json")
|
|
64
|
-
|
|
60
|
+
# self._file_config: File = self.value.work_dir.concat("config", True).join_file("app_config.json")
|
|
61
|
+
|
|
65
62
|
def set_work_dir(self, d: Directory):
|
|
66
63
|
self._value.work_dir = d
|
|
67
64
|
self.notify_listeners()
|
|
68
|
-
|
|
65
|
+
|
|
69
66
|
def set_initial_dir(self, d: Directory):
|
|
70
67
|
self._value.initial_dir = d
|
|
71
68
|
self.notify_listeners()
|
|
72
|
-
|
|
69
|
+
|
|
73
70
|
def set_documents_dir(self, d: Directory):
|
|
74
71
|
self._value.documents_dir = d
|
|
75
72
|
self.notify_listeners()
|
|
76
|
-
|
|
73
|
+
|
|
77
74
|
def get_file_config(self) -> File:
|
|
78
75
|
return AppConfigNotifier.file_config
|
|
79
|
-
|
|
76
|
+
|
|
80
77
|
def get_dict_config(self) -> dict[str, str]:
|
|
81
78
|
final = dict()
|
|
82
79
|
final["initial_dir"] = self.value.initial_dir.absolute()
|
|
@@ -85,29 +82,28 @@ class AppConfigNotifier(ValueNotifier[MapConfig]):
|
|
|
85
82
|
final["documents_dir"] = self.value.documents_dir.absolute()
|
|
86
83
|
final["theme_mode"] = self.value.theme_mode.value
|
|
87
84
|
return final
|
|
88
|
-
|
|
85
|
+
|
|
89
86
|
def save_config(self):
|
|
90
87
|
converter = JsonConvert.from_dict(self.get_dict_config())
|
|
91
88
|
converter.data.to_file(self.get_file_config())
|
|
92
|
-
print(f
|
|
89
|
+
print(f"Configurações salvas em ... {self.get_file_config().absolute()}")
|
|
93
90
|
|
|
94
91
|
def notify_listeners(self) -> None:
|
|
95
92
|
"""
|
|
96
|
-
|
|
93
|
+
Salvar a nova configuração em arquivo local e notificar os observadores.
|
|
97
94
|
"""
|
|
98
95
|
self.save_config()
|
|
99
96
|
return super().notify_listeners()
|
|
100
|
-
|
|
97
|
+
|
|
101
98
|
@classmethod
|
|
102
99
|
def create(cls) -> AppConfigNotifier:
|
|
103
100
|
src = Directory(cls.file_config.dirname())
|
|
104
101
|
src.mkdir()
|
|
105
|
-
|
|
102
|
+
|
|
106
103
|
config: MapConfig
|
|
107
104
|
if cls.file_config.exists():
|
|
108
|
-
print(f
|
|
105
|
+
print(f"Lendo configração em ... {cls.file_config.absolute()}")
|
|
109
106
|
config = FactoryMapConfig().create_from_file(cls.file_config)
|
|
110
107
|
else:
|
|
111
108
|
config = FactoryMapConfig().create_default()
|
|
112
109
|
return cls(config)
|
|
113
|
-
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
from pyflutter_ui import (
|
|
2
|
-
ChangeNotifier,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
ChangeNotifier,
|
|
3
|
+
BuildContext,
|
|
4
|
+
FlutterWidget,
|
|
5
|
+
LinearProgress,
|
|
6
|
+
StatelessWidget,
|
|
7
|
+
Consumer,
|
|
8
|
+
Column,
|
|
9
|
+
Row,
|
|
10
|
+
ElevatedButton,
|
|
11
|
+
Expanded,
|
|
12
|
+
Divider,
|
|
13
|
+
MainAxisAlignment,
|
|
14
|
+
Scaffold,
|
|
15
|
+
Text,
|
|
16
|
+
ValueListenableBuilder,
|
|
17
|
+
Provider,
|
|
18
|
+
DropdownButton,
|
|
19
|
+
FilePickerController,
|
|
20
|
+
FilePickerResult,
|
|
21
|
+
FilePickerType,
|
|
22
|
+
PlatformFile,
|
|
7
23
|
)
|
|
8
24
|
|
|
9
25
|
from tkinter import messagebox
|
|
@@ -12,22 +28,28 @@ import pandas as pd
|
|
|
12
28
|
from pandas import DataFrame
|
|
13
29
|
|
|
14
30
|
|
|
15
|
-
from table_stream
|
|
16
|
-
|
|
17
|
-
|
|
31
|
+
from table_stream import (
|
|
32
|
+
ArrayList,
|
|
33
|
+
HashMapDict,
|
|
34
|
+
csvEncoding,
|
|
35
|
+
csvSeparator,
|
|
36
|
+
File,
|
|
37
|
+
Directory,
|
|
38
|
+
)
|
|
18
39
|
|
|
19
40
|
from converter.home_page.controller import ControllerHomePage
|
|
20
41
|
from converter.table_widget import TableOrProgress
|
|
21
42
|
from converter.home_page._page_edit import PageEditExcel
|
|
22
43
|
|
|
23
|
-
# Páginas
|
|
44
|
+
# Páginas para navegação.
|
|
24
45
|
from converter.page_forms import PageRespondsForms
|
|
25
46
|
from converter.page_forms import ControllerForms
|
|
26
47
|
from converter.config_app import MapConfig, AppConfigNotifier
|
|
48
|
+
from converter.page_image import PageImage
|
|
27
49
|
|
|
28
50
|
|
|
29
51
|
class HomePage(StatelessWidget):
|
|
30
|
-
|
|
52
|
+
|
|
31
53
|
def __init__(self, key: str | None = None) -> None:
|
|
32
54
|
super().__init__(key)
|
|
33
55
|
|
|
@@ -36,20 +58,20 @@ class HomePage(StatelessWidget):
|
|
|
36
58
|
|
|
37
59
|
|
|
38
60
|
class _HomePageState(StatelessWidget):
|
|
39
|
-
|
|
61
|
+
|
|
40
62
|
def __init__(self, key: str | None = None) -> None:
|
|
41
63
|
super().__init__(key)
|
|
42
64
|
self.context: BuildContext = None
|
|
43
|
-
|
|
44
|
-
initial_dir: Directory = self.app_config.value.initial_dir
|
|
45
|
-
|
|
65
|
+
|
|
66
|
+
initial_dir: Directory = self.app_config.value.initial_dir
|
|
67
|
+
|
|
46
68
|
self._pick = FilePickerController(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
69
|
+
type=FilePickerType.spreadsheet,
|
|
70
|
+
allow_multiple=True,
|
|
71
|
+
dialog_title="Escolha Planilhas",
|
|
72
|
+
initial_directory=initial_dir.absolute() if initial_dir.exists() else None,
|
|
73
|
+
)
|
|
74
|
+
|
|
53
75
|
self.mapping_csv_sep = HashMapDict[str, csvSeparator](
|
|
54
76
|
{
|
|
55
77
|
"tabulação": "\t",
|
|
@@ -58,102 +80,106 @@ class _HomePageState(StatelessWidget):
|
|
|
58
80
|
"virgula": ",",
|
|
59
81
|
}
|
|
60
82
|
)
|
|
61
|
-
self.mapping_csv_enc = HashMapDict[str, csvEncoding](
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
83
|
+
self.mapping_csv_enc = HashMapDict[str, csvEncoding](
|
|
84
|
+
{
|
|
85
|
+
"utf8": "utf-8",
|
|
86
|
+
"cp1252": "cp1252",
|
|
87
|
+
"iso-8859-1": "iso-8859-1",
|
|
88
|
+
"latin": "latin1",
|
|
89
|
+
}
|
|
90
|
+
)
|
|
67
91
|
|
|
68
92
|
self.controller.show_error = self.show_error
|
|
69
93
|
self.controller.show_msg = self.show_message
|
|
70
|
-
|
|
94
|
+
|
|
71
95
|
@property
|
|
72
96
|
def app_config(self) -> AppConfigNotifier:
|
|
73
97
|
state = Provider.read(AppConfigNotifier)
|
|
74
98
|
return state
|
|
75
|
-
|
|
99
|
+
|
|
76
100
|
@property
|
|
77
101
|
def controller(self) -> ControllerHomePage:
|
|
78
102
|
return Provider.read(ControllerHomePage)
|
|
79
|
-
|
|
103
|
+
|
|
80
104
|
def file_picker_excel(self, controller: ControllerHomePage):
|
|
81
105
|
"""
|
|
82
106
|
Selecionar um ou mais arquivos/planilhas e empilhar junto com
|
|
83
107
|
os arquivos escolhidos anteriormente.
|
|
84
108
|
"""
|
|
85
|
-
|
|
109
|
+
|
|
86
110
|
result: FilePickerResult = self._pick.pick_files()
|
|
87
111
|
if result is None:
|
|
88
112
|
return
|
|
89
|
-
|
|
113
|
+
|
|
90
114
|
self.app_config.set_initial_dir(Directory(self._pick.initial_directory))
|
|
91
|
-
|
|
115
|
+
|
|
92
116
|
files: list[PlatformFile] = result.files
|
|
93
117
|
final_files: ArrayList[File] = ArrayList()
|
|
94
|
-
|
|
118
|
+
|
|
95
119
|
f: PlatformFile
|
|
96
120
|
for f in files:
|
|
97
121
|
final_files.append(File(f.path))
|
|
98
122
|
controller.add_files(final_files)
|
|
99
|
-
|
|
123
|
+
|
|
100
124
|
if controller.get_file_sheet() is None:
|
|
101
125
|
controller.set_file_sheet(controller.files.get_first())
|
|
102
|
-
|
|
126
|
+
|
|
103
127
|
def show_message(self, txt: str):
|
|
104
128
|
messagebox.showinfo("Aviso", txt)
|
|
105
129
|
|
|
106
130
|
def show_error(self, e: str):
|
|
107
131
|
messagebox.showerror("Erro", e)
|
|
108
|
-
|
|
132
|
+
|
|
109
133
|
def action_selected_file(self, name: str):
|
|
110
134
|
"""Alterar o arquivo selecionado no controller"""
|
|
111
135
|
if self.controller.running:
|
|
112
136
|
self.show_error("Existe outra operação em andamento")
|
|
113
137
|
return
|
|
114
|
-
|
|
138
|
+
|
|
115
139
|
value: HashMapDict = self.controller.files_notifier.value
|
|
116
140
|
|
|
117
141
|
if not value.header().contains(name):
|
|
118
|
-
msg = f
|
|
142
|
+
msg = f"O arquivo {name} NÃO foi importado!"
|
|
119
143
|
self.show_message(msg)
|
|
120
144
|
return
|
|
121
|
-
|
|
145
|
+
|
|
122
146
|
current_file = value.get_value(name)
|
|
123
|
-
self.controller.set_file_sheet(current_file)
|
|
124
|
-
|
|
147
|
+
self.controller.set_file_sheet(current_file)
|
|
148
|
+
|
|
125
149
|
def action_selected_sheet_name(self, name: str):
|
|
126
150
|
if self.controller.running:
|
|
127
151
|
messagebox.showerror("Erro", "Existe outra operação em andamento")
|
|
128
152
|
controller: ControllerHomePage = self.controller
|
|
129
153
|
controller.sheet_name = name
|
|
130
|
-
|
|
154
|
+
|
|
131
155
|
def action_clear_data(self, context: BuildContext):
|
|
132
156
|
self.controller.data_notifier.clear()
|
|
133
157
|
self.controller.notify_listeners()
|
|
134
|
-
|
|
158
|
+
|
|
135
159
|
def action_btn_load_data(self, context: BuildContext):
|
|
136
160
|
"""
|
|
137
|
-
|
|
161
|
+
Ação do botão para ler Dados
|
|
138
162
|
"""
|
|
139
163
|
if self.controller.running:
|
|
140
164
|
messagebox.showerror("Erro", "Existe outra operação em andamento")
|
|
141
|
-
|
|
165
|
+
|
|
142
166
|
if self.controller.get_file_sheet() is None:
|
|
143
167
|
messagebox.showerror("Falha", "Selecione planilhas para prosseguir")
|
|
144
168
|
return
|
|
145
|
-
|
|
169
|
+
|
|
146
170
|
self.controller.command_load_data()
|
|
147
|
-
|
|
171
|
+
|
|
148
172
|
def action_csv_separator(self, name: str):
|
|
149
173
|
self.controller.csv_options.separator = self.mapping_csv_sep.get_value(name)
|
|
150
|
-
|
|
174
|
+
|
|
151
175
|
def action_csv_enc(self, name: str):
|
|
152
176
|
self.controller.csv_options.encoding = self.mapping_csv_enc.get_value(name)
|
|
153
|
-
|
|
154
|
-
def _builder_list_files(
|
|
177
|
+
|
|
178
|
+
def _builder_list_files(
|
|
179
|
+
self, context: BuildContext, map_files: HashMapDict[str, File]
|
|
180
|
+
):
|
|
155
181
|
"""Gerar o widget que exibe a lista de arquivos selecionados"""
|
|
156
|
-
|
|
182
|
+
|
|
157
183
|
if map_files.header().size() < 1:
|
|
158
184
|
return Text("Nenhum arquivo selecionado")
|
|
159
185
|
|
|
@@ -166,73 +192,79 @@ class _HomePageState(StatelessWidget):
|
|
|
166
192
|
|
|
167
193
|
return Row(
|
|
168
194
|
children=[
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
def _builder_sheet_names(
|
|
195
|
+
Text(f"({map_files.header().size()})"),
|
|
196
|
+
Divider(orientation="horizontal"),
|
|
197
|
+
Expanded(
|
|
198
|
+
DropdownButton(
|
|
199
|
+
map_files.header(),
|
|
200
|
+
file_name,
|
|
201
|
+
on_changed=self.action_selected_file,
|
|
202
|
+
)
|
|
203
|
+
),
|
|
204
|
+
]
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
def _builder_sheet_names(
|
|
208
|
+
self, context: BuildContext, controller: ControllerHomePage
|
|
209
|
+
):
|
|
182
210
|
"""Exibe a lista de abas da planilha selecionada"""
|
|
183
211
|
if controller.sheet_name is None:
|
|
184
212
|
return Text("Nenhuma aba carregada!")
|
|
185
|
-
|
|
213
|
+
|
|
186
214
|
return DropdownButton(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
def _build_table(
|
|
215
|
+
controller.sheet_names,
|
|
216
|
+
controller.sheet_name,
|
|
217
|
+
on_changed=self.action_selected_sheet_name,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
def _build_table(
|
|
221
|
+
self, context: BuildContext, controller: ControllerHomePage
|
|
222
|
+
) -> TableOrProgress:
|
|
193
223
|
"""Exibe os dados do DataFrame atual"""
|
|
194
|
-
|
|
195
|
-
|
|
224
|
+
|
|
196
225
|
data = controller.data_notifier.value
|
|
197
226
|
if data.empty:
|
|
198
|
-
data = pd.DataFrame({
|
|
199
|
-
|
|
227
|
+
data = pd.DataFrame({"A": ["Tabela vazia"]})
|
|
228
|
+
|
|
200
229
|
return TableOrProgress(
|
|
201
230
|
running=controller.data_notifier.running,
|
|
202
231
|
df=data.head(),
|
|
203
232
|
)
|
|
204
|
-
|
|
233
|
+
|
|
205
234
|
def action_open_forms(self, context: BuildContext, controller: ControllerHomePage):
|
|
206
235
|
"""
|
|
207
236
|
Seta o DataFrame() da página atual como propriedade do ControllerForms()
|
|
208
237
|
antes de carregar a página.
|
|
209
238
|
"""
|
|
210
|
-
#df = controller.data_notifier.value
|
|
211
|
-
#forms_controller: ControllerForms = context.read(ControllerForms)
|
|
212
|
-
#forms_controller.set_data(df)
|
|
213
|
-
#if not forms_controller.forms_state.data_is_valid():
|
|
239
|
+
# df = controller.data_notifier.value
|
|
240
|
+
# forms_controller: ControllerForms = context.read(ControllerForms)
|
|
241
|
+
# forms_controller.set_data(df)
|
|
242
|
+
# if not forms_controller.forms_state.data_is_valid():
|
|
214
243
|
# messagebox.showerror("Erro", "Tabela TOI inválida")
|
|
215
244
|
# return
|
|
216
|
-
|
|
245
|
+
|
|
217
246
|
context.navigator.push(PageRespondsForms())
|
|
218
|
-
|
|
219
|
-
def _builder_body(
|
|
247
|
+
|
|
248
|
+
def _builder_body(
|
|
249
|
+
self, context: BuildContext, controller: ControllerHomePage
|
|
250
|
+
) -> FlutterWidget:
|
|
220
251
|
self.context = context
|
|
221
|
-
|
|
252
|
+
|
|
222
253
|
filename = controller.get_file_sheet()
|
|
223
254
|
if filename is not None:
|
|
224
255
|
filename = filename.basename()
|
|
225
|
-
|
|
256
|
+
|
|
226
257
|
return Column(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
258
|
+
children=[
|
|
259
|
+
# -----------------------------------#
|
|
260
|
+
# Topo - importação de arquivos.
|
|
261
|
+
Row(
|
|
231
262
|
children=[
|
|
232
263
|
ElevatedButton(
|
|
233
|
-
"Selecionar planilha",
|
|
264
|
+
"Selecionar planilha",
|
|
265
|
+
on_pressed=lambda: self.file_picker_excel(controller),
|
|
234
266
|
),
|
|
235
|
-
Divider(orientation=
|
|
267
|
+
Divider(orientation="horizontal"),
|
|
236
268
|
# Lista de arquivos importados
|
|
237
269
|
ValueListenableBuilder[HashMapDict[str, File]](
|
|
238
270
|
controller.files_notifier, self._builder_list_files
|
|
@@ -240,67 +272,74 @@ class _HomePageState(StatelessWidget):
|
|
|
240
272
|
Divider(),
|
|
241
273
|
# Lista de abas da planilha selecionada.
|
|
242
274
|
Consumer(
|
|
243
|
-
ControllerHomePage,
|
|
275
|
+
ControllerHomePage,
|
|
276
|
+
self._builder_sheet_names,
|
|
244
277
|
),
|
|
245
278
|
],
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
279
|
+
), ## Row
|
|
280
|
+
# Limpar/Carregar dados - opções CSV.
|
|
281
|
+
Row(
|
|
282
|
+
[
|
|
283
|
+
ElevatedButton(
|
|
284
|
+
"Limpar", lambda: self.action_clear_data(context)
|
|
285
|
+
),
|
|
286
|
+
ElevatedButton(
|
|
287
|
+
"Carregar", lambda: self.action_btn_load_data(context)
|
|
288
|
+
),
|
|
289
|
+
Divider(orientation="horizontal"),
|
|
290
|
+
Column(
|
|
291
|
+
[
|
|
292
|
+
Text("Separador"),
|
|
293
|
+
DropdownButton(
|
|
257
294
|
self.mapping_csv_sep.header(),
|
|
258
295
|
"tabulação",
|
|
259
296
|
on_changed=self.action_csv_separator,
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
297
|
+
),
|
|
298
|
+
]
|
|
299
|
+
), ## Column
|
|
300
|
+
Column(
|
|
301
|
+
[
|
|
302
|
+
Text("Encoding"),
|
|
303
|
+
DropdownButton(
|
|
267
304
|
self.mapping_csv_enc.header(),
|
|
268
305
|
"utf8",
|
|
269
306
|
on_changed=self.action_csv_enc,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
307
|
+
),
|
|
308
|
+
]
|
|
309
|
+
), ## Column
|
|
310
|
+
],
|
|
311
|
+
main_axis_alignment=MainAxisAlignment.START,
|
|
312
|
+
), ## Row
|
|
313
|
+
Divider(),
|
|
314
|
+
Expanded(Consumer(ControllerHomePage, self._build_table)),
|
|
315
|
+
Row(
|
|
316
|
+
[
|
|
317
|
+
Text("Ir para: "),
|
|
318
|
+
ElevatedButton(
|
|
319
|
+
"Edição de dados",
|
|
320
|
+
lambda: context.navigator.push(PageEditExcel()),
|
|
321
|
+
),
|
|
322
|
+
# ElevatedButton("Exportar dados", lambda: print()),
|
|
323
|
+
ElevatedButton(
|
|
324
|
+
"Responds Forms",
|
|
325
|
+
lambda: self.action_open_forms(context, controller),
|
|
326
|
+
),
|
|
327
|
+
ElevatedButton(
|
|
328
|
+
"Renomear imagens",
|
|
329
|
+
lambda: context.navigator.push(PageImage()),
|
|
330
|
+
),
|
|
331
|
+
],
|
|
332
|
+
main_axis_alignment=MainAxisAlignment.START,
|
|
333
|
+
),
|
|
334
|
+
]
|
|
335
|
+
)
|
|
336
|
+
|
|
298
337
|
def build(self, context: BuildContext) -> FlutterWidget:
|
|
299
338
|
self.context = context
|
|
300
|
-
|
|
339
|
+
|
|
301
340
|
return Scaffold(
|
|
302
|
-
|
|
341
|
+
Consumer(
|
|
342
|
+
ControllerHomePage,
|
|
343
|
+
builder=self._builder_body,
|
|
303
344
|
)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
345
|
+
)
|