pyflutter-app 0.2.0__tar.gz → 0.2.2__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.2.0 → pyflutter_app-0.2.2}/PKG-INFO +2 -2
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/page_forms/__init__.py +81 -117
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/page_forms/controller_forms.py +27 -3
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/table_widget.py +7 -7
- pyflutter_app-0.2.2/main.py +63 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/navigator.py +4 -4
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/ui/buttons.py +34 -34
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/ui/container.py +16 -16
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/ui/core.py +80 -56
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/ui/list_builder.py +28 -43
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/ui/progress.py +9 -9
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/ui/tables.py +14 -14
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/ui/widgets.py +281 -128
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyproject.toml +2 -2
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/file_names.py +8 -11
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/uv.lock +116 -9
- pyflutter_app-0.2.0/main.py +0 -17
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/.gitignore +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/.idea/.gitignore +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/.idea/inspectionProfiles/Project_Default.xml +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/.idea/inspectionProfiles/profiles_settings.xml +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/.idea/misc.xml +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/.idea/modules.xml +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/.idea/pyflutter_app.iml +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/.idea/vcs.xml +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/README.md +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/__init__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/__main__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/assets/forms_config.json +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/config_app.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/home_page/__init__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/home_page/_page_edit.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/home_page/controller.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/home_page/model.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/home_page/view.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/lib_toi.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/page_forms/common.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/page_forms/config.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/page_forms/model_forms.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/page_forms/service.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/run.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/util.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/whatsapp/__init__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/converter/whatsapp/model.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/export_app.sh +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/local_build/linux.sh +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/local_build/send.sh +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/__init__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/app.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/file_picker.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/scheduler.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/theme.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/pyflutter_ui/ui/__init__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/__init__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/erros.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/hash_map.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/notifier.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/pattner/__init__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/pattner/adapter.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/sheet/__init__.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/sheet/check_mod.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/sheet/load.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/sheet/options.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/sheet/parse.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/sheet/save.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/state.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/sysfiles.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/thread.py +0 -0
- {pyflutter_app-0.2.0 → pyflutter_app-0.2.2}/table_stream/workbook.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pyflutter_app
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Bibliotecas Python para conversão de documentos, interface e processamento de tabelas.
|
|
5
|
-
Requires-Python: >=3.
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
6
|
Requires-Dist: openpyxl>=3.1.5
|
|
7
7
|
Requires-Dist: pandas-stubs~=3.0.3
|
|
8
8
|
Requires-Dist: pandas>=3.0.0
|
|
@@ -71,135 +71,103 @@ class _PageRespondsFormsState(StatelessWidget):
|
|
|
71
71
|
|
|
72
72
|
def show_message(self, m: str):
|
|
73
73
|
messagebox.showinfo("Aviso", m)
|
|
74
|
-
|
|
75
|
-
def build_btn_load_and_export(self) -> Row:
|
|
76
|
-
"""
|
|
77
|
-
Retorna o botão para exportar os documentos em formato Excel/CSV
|
|
78
|
-
"""
|
|
79
|
-
return Row(
|
|
80
|
-
[
|
|
81
|
-
ElevatedButton("Importar Tabela", self.controller.action_load_file, ),
|
|
82
|
-
ElevatedButton("Gerar Planilha", self.controller.action_table_tois, )
|
|
83
|
-
]
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def build_select_cartas_dir(self, context: BuildContext, forms_state: FormsState) -> FlutterWidget:
|
|
88
|
-
"""
|
|
89
|
-
Botões superiores para selecionar arquivos e diretórios.
|
|
90
|
-
"""
|
|
91
|
-
state = self.controller.state_value
|
|
92
|
-
|
|
93
|
-
if forms_state.running:
|
|
94
|
-
return Expanded(LinearProgress(indeterminate=True))
|
|
95
|
-
|
|
96
|
-
if state.is_error():
|
|
97
|
-
self.show_error(f"{state.get_exception()}")
|
|
98
|
-
|
|
99
|
-
dir_docs = forms_state.get_documents_dir().absolute()
|
|
100
|
-
work_dir = forms_state.get_work_dir().basename()
|
|
101
|
-
|
|
102
|
-
if len(dir_docs) > self._max_char_names:
|
|
103
|
-
num_chars: int = int(self._max_char_names/2)
|
|
104
|
-
first = dir_docs[0:num_chars]
|
|
105
|
-
last = dir_docs[-num_chars:]
|
|
106
|
-
dir_docs = f'{first}...{last}'
|
|
107
|
-
|
|
108
|
-
return Row(
|
|
109
|
-
[
|
|
110
|
-
ElevatedButton(
|
|
111
|
-
"Pasta de trabalho",
|
|
112
|
-
lambda: self.picker_work_dir()
|
|
113
|
-
),
|
|
114
|
-
Divider(),
|
|
115
|
-
Text(work_dir),
|
|
116
|
-
self.build_btn_load_and_export(),
|
|
117
|
-
|
|
118
|
-
ElevatedButton(
|
|
119
|
-
"Pasta de documentos",
|
|
120
|
-
lambda: self.picker_directory(forms_state.set_documents_dir)
|
|
121
|
-
),
|
|
122
|
-
Divider(),
|
|
123
|
-
Text(dir_docs),
|
|
124
|
-
]
|
|
125
|
-
)
|
|
126
|
-
|
|
127
74
|
|
|
128
75
|
def _builder_widget_row(
|
|
129
76
|
self,
|
|
130
77
|
context: BuildContext,
|
|
131
78
|
idx: int,
|
|
132
79
|
info: RowTable
|
|
133
|
-
) ->
|
|
80
|
+
) -> Text:
|
|
134
81
|
text_info = f"{idx} ID {info.result.index} UC {info.uc} TOI {info.toi} STATUS {info.result.status.value}"
|
|
135
82
|
return Text(text_info)
|
|
136
83
|
|
|
137
|
-
def
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
print("quantidade:", map_rows.values().size())
|
|
145
|
-
|
|
146
|
-
widgets = []
|
|
84
|
+
def build_forms_rows(self, context: BuildContext, map_rows: MapRows) -> Column:
|
|
85
|
+
|
|
86
|
+
print("=" * 80)
|
|
87
|
+
print(f"[DEBUG] BUILD_WIDGETS_ROWS ... quantidade => {map_rows.values().size()}")
|
|
88
|
+
|
|
89
|
+
list_widgets = []
|
|
90
|
+
row: RowTable
|
|
147
91
|
|
|
148
92
|
for idx, row in enumerate(map_rows.values()):
|
|
149
|
-
print(
|
|
93
|
+
print('=' * 80)
|
|
94
|
+
print(f"{__class__.__name__} Criando Widget Row: {idx} {row.uc}")
|
|
95
|
+
list_widgets.append(self._builder_widget_row(context, idx, row))
|
|
150
96
|
|
|
151
|
-
|
|
152
|
-
self._builder_widget_row(
|
|
153
|
-
context,
|
|
154
|
-
idx,
|
|
155
|
-
row
|
|
156
|
-
)
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
return Column([
|
|
160
|
-
Row([
|
|
161
|
-
ElevatedButton(
|
|
162
|
-
"Parar" if controller.state_value.is_running() else "Iniciar",
|
|
163
|
-
controller.stop_forms
|
|
164
|
-
if controller.state_value.is_running()
|
|
165
|
-
else controller.start_forms,
|
|
166
|
-
),
|
|
167
|
-
Expanded(
|
|
168
|
-
Text(f"Cartas: {map_rows.values().size()}")
|
|
169
|
-
),
|
|
170
|
-
Text(
|
|
171
|
-
f"Status linha atual: "
|
|
172
|
-
f"{ResultStatus.status.value}"
|
|
173
|
-
),
|
|
174
|
-
]),
|
|
175
|
-
|
|
176
|
-
Column(widgets),
|
|
177
|
-
])
|
|
97
|
+
return Column(list_widgets)
|
|
178
98
|
|
|
179
99
|
|
|
180
100
|
def build_body(self, context: BuildContext, forms_state: FormsState) -> FlutterWidget:
|
|
181
101
|
"""
|
|
182
102
|
Parte central do app.
|
|
183
103
|
"""
|
|
184
|
-
|
|
185
|
-
|
|
104
|
+
if forms_state.running:
|
|
105
|
+
return Expanded(LinearProgress(indeterminate=True))
|
|
106
|
+
|
|
107
|
+
state = self.controller.state_value
|
|
108
|
+
if state.is_error():
|
|
109
|
+
self.show_error(f"{state.get_exception()}")
|
|
186
110
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
111
|
+
# Botões superiores para selecionar arquivos e diretórios.
|
|
112
|
+
dir_docs: str = forms_state.get_documents_dir().basename()
|
|
113
|
+
work_dir: str = forms_state.get_work_dir().basename()
|
|
190
114
|
|
|
115
|
+
if len(dir_docs) > self._max_char_names:
|
|
116
|
+
num_chars: int = int(self._max_char_names/2)
|
|
117
|
+
first = dir_docs[0:num_chars]
|
|
118
|
+
last = dir_docs[-num_chars:]
|
|
119
|
+
dir_docs = f'{first}...{last}'
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# Botões para PARAR, CONTINUAR e exibir status da linha atual.
|
|
123
|
+
controller = self.controller
|
|
124
|
+
_is_running = controller.state_value.is_running()
|
|
125
|
+
_command_star_or_stop = controller.stop_forms if _is_running else controller.start_forms
|
|
126
|
+
|
|
191
127
|
return Column(
|
|
192
128
|
[
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
129
|
+
# Topo do App
|
|
130
|
+
Row([
|
|
131
|
+
Expanded(
|
|
132
|
+
|
|
133
|
+
Row(
|
|
134
|
+
[
|
|
135
|
+
Row([
|
|
136
|
+
ElevatedButton("Importar Tabela", self.controller.action_load_file, ),
|
|
137
|
+
ElevatedButton("Gerar Planilha", self.controller.action_table_tois, )
|
|
138
|
+
]),
|
|
139
|
+
Divider(),
|
|
140
|
+
Divider(),
|
|
141
|
+
|
|
142
|
+
ElevatedButton("Pasta de trabalho", lambda: self.picker_work_dir()),
|
|
143
|
+
Text(work_dir),
|
|
144
|
+
Divider(),
|
|
145
|
+
|
|
146
|
+
ElevatedButton("Pasta de documentos", lambda: self.picker_directory(forms_state.set_documents_dir)),
|
|
147
|
+
Text(dir_docs),
|
|
148
|
+
Divider(),
|
|
149
|
+
]
|
|
150
|
+
)
|
|
151
|
+
),
|
|
152
|
+
]),
|
|
196
153
|
|
|
197
154
|
Divider(),
|
|
198
|
-
Row(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
155
|
+
Row([
|
|
156
|
+
ElevatedButton("Parar" if _is_running else "Iniciar", _command_star_or_stop,),
|
|
157
|
+
|
|
158
|
+
Expanded(
|
|
159
|
+
Text(f"Total Cartas: {forms_state.map_row_notifier.total_rows()}")
|
|
160
|
+
),
|
|
161
|
+
|
|
162
|
+
Text(
|
|
163
|
+
f"Status linha atual: "
|
|
164
|
+
f"{ResultStatus.status.value}"
|
|
165
|
+
),
|
|
166
|
+
]),
|
|
167
|
+
Expanded(
|
|
168
|
+
ValueListenableBuilder(forms_state.map_row_notifier, self.build_forms_rows),
|
|
169
|
+
),
|
|
170
|
+
|
|
203
171
|
]
|
|
204
172
|
)
|
|
205
173
|
|
|
@@ -208,20 +176,16 @@ class _PageRespondsFormsState(StatelessWidget):
|
|
|
208
176
|
self.context = context
|
|
209
177
|
|
|
210
178
|
return Scaffold(
|
|
211
|
-
Column(
|
|
212
|
-
[
|
|
213
|
-
# Topo do App
|
|
214
|
-
Row(
|
|
215
|
-
[
|
|
216
|
-
Expanded(
|
|
217
|
-
Consumer(FormsState, self.build_select_cartas_dir)
|
|
218
|
-
),
|
|
219
|
-
]
|
|
220
|
-
),
|
|
179
|
+
Column([
|
|
221
180
|
# Corpo do App
|
|
222
181
|
Consumer(FormsState, self.build_body),
|
|
223
182
|
|
|
224
|
-
|
|
183
|
+
# Base do App
|
|
184
|
+
Divider(),
|
|
185
|
+
Row([
|
|
186
|
+
ElevatedButton("<- Voltar", lambda: context.navigator.pop()),
|
|
187
|
+
]),
|
|
188
|
+
|
|
189
|
+
])
|
|
225
190
|
)
|
|
226
|
-
)
|
|
227
191
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# converter/page_forms/controller_forms.py
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
import pandas as pd
|
|
4
|
-
from typing import Callable
|
|
4
|
+
from typing import Any, Callable, TypeVar
|
|
5
5
|
|
|
6
6
|
from converter.util import (
|
|
7
7
|
Directory, File,
|
|
@@ -15,6 +15,28 @@ from pyflutter_ui.ui import ValueNotifier, ChangeNotifier, Provider
|
|
|
15
15
|
from converter.page_forms.model_forms import ModelForms
|
|
16
16
|
from converter.config_app import AppConfigNotifier
|
|
17
17
|
|
|
18
|
+
V = TypeVar('V')
|
|
19
|
+
|
|
20
|
+
class ValueNotifierState(ValueNotifier[V]):
|
|
21
|
+
|
|
22
|
+
def __init__(self, value: V) -> None:
|
|
23
|
+
super().__init__(value)
|
|
24
|
+
self.state_value: ThreadStateValue = ThreadStateValue()
|
|
25
|
+
|
|
26
|
+
def is_running(self) -> bool:
|
|
27
|
+
return self.state_value.is_running()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class MapRowsNotifier(ValueNotifierState[MapRows]):
|
|
32
|
+
|
|
33
|
+
def __init__(self, value: MapRows) -> None:
|
|
34
|
+
super().__init__(value)
|
|
35
|
+
Provider.add_state(self)
|
|
36
|
+
|
|
37
|
+
def total_rows(self) -> int:
|
|
38
|
+
return self.get_value().values().size()
|
|
39
|
+
|
|
18
40
|
|
|
19
41
|
class FormsState(ChangeNotifier):
|
|
20
42
|
"""
|
|
@@ -27,9 +49,10 @@ class FormsState(ChangeNotifier):
|
|
|
27
49
|
|
|
28
50
|
self.running: bool = False
|
|
29
51
|
self.data = pd.DataFrame()
|
|
30
|
-
self.map_rows = MapRows()
|
|
52
|
+
#self.map_rows = MapRows()
|
|
31
53
|
self.func_show_error: Callable[[str], None] = None
|
|
32
54
|
self.func_show_msg: Callable[[str], None] = None
|
|
55
|
+
self.map_row_notifier = MapRowsNotifier(MapRows())
|
|
33
56
|
|
|
34
57
|
def show_message(self, m: str):
|
|
35
58
|
if self.func_show_msg is None:
|
|
@@ -47,7 +70,8 @@ class FormsState(ChangeNotifier):
|
|
|
47
70
|
|
|
48
71
|
self.data = tb
|
|
49
72
|
factory = FactoryRowTable(self.data)
|
|
50
|
-
|
|
73
|
+
|
|
74
|
+
self.map_row_notifier.value = factory.create_map()
|
|
51
75
|
self.notify_listeners()
|
|
52
76
|
|
|
53
77
|
def set_running(self, r: bool):
|
|
@@ -32,11 +32,11 @@ class _TableOrProgressElement(Element[ttk.Frame]):
|
|
|
32
32
|
self._scrollbar_x: ttk.Scrollbar = None
|
|
33
33
|
self._scrollbar_y: ttk.Scrollbar = None
|
|
34
34
|
|
|
35
|
-
def
|
|
36
|
-
return self.
|
|
35
|
+
def get_widget_flutter(self) -> TableOrProgress:
|
|
36
|
+
return self.widget_flutter # type: ignore
|
|
37
37
|
|
|
38
|
-
def
|
|
39
|
-
return super().
|
|
38
|
+
def get_widget_tk(self) -> ttk.Frame:
|
|
39
|
+
return super().get_widget_tk()
|
|
40
40
|
|
|
41
41
|
def mount(self, context: BuildContext) -> ttk.Frame:
|
|
42
42
|
super().mount(context)
|
|
@@ -60,13 +60,13 @@ class _TableOrProgressElement(Element[ttk.Frame]):
|
|
|
60
60
|
self._scrollbar_y.configure(command=self._tree.yview)
|
|
61
61
|
self._scrollbar_x.configure(command=self._tree.xview)
|
|
62
62
|
|
|
63
|
-
self.
|
|
64
|
-
self.update_table(self.
|
|
63
|
+
self.widget_tk = self._frame
|
|
64
|
+
self.update_table(self.get_widget_flutter())
|
|
65
65
|
return self._frame
|
|
66
66
|
|
|
67
67
|
def update(self, new_widget: FlutterWidget) -> None:
|
|
68
68
|
super().update(new_widget)
|
|
69
|
-
self.update_table(self.
|
|
69
|
+
self.update_table(self.get_widget_flutter())
|
|
70
70
|
|
|
71
71
|
def _clear_tree(self) -> None:
|
|
72
72
|
if self._tree is None:
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from converter.util import (
|
|
4
|
+
SheetLoader, OptionsIOSheet, SheetType, ControllerThread,
|
|
5
|
+
StateValue, ThreadStateValue, File, Directory, ArrayList, ContentFiles
|
|
6
|
+
)
|
|
7
|
+
from table_stream.file_names import (
|
|
8
|
+
ColumnsWhatsApp, load_whatsapp_txt, FactoryCreateMapDocuments, FactoryCreateMapDocumentsWhatsapp,
|
|
9
|
+
FactoryNameDocument, ORGANIZABLE_DOC_NAME, OrganizeDocumentsNames,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def save(src_file: File, final_dir: Directory):
|
|
14
|
+
if not src_file.exists():
|
|
15
|
+
print(f'O arquivo não existe ... {src_file.absolute()}')
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
df = load_whatsapp_txt(src_file)
|
|
19
|
+
if df.empty:
|
|
20
|
+
print(f'DataFrame() vazio!!!')
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
src = Directory(src_file.dirname())
|
|
24
|
+
|
|
25
|
+
factory = FactoryCreateMapDocumentsWhatsapp(df, src)
|
|
26
|
+
|
|
27
|
+
organize = OrganizeDocumentsNames(final_dir, include_day=False)
|
|
28
|
+
organize.organize(factory.create_map_names())
|
|
29
|
+
|
|
30
|
+
print(f'save() ... OK => {final_dir.absolute()}')
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def get_file_txt(d: Directory) -> File:
|
|
34
|
+
content = ContentFiles(d)
|
|
35
|
+
files = content.get_files_with(infile='.txt')
|
|
36
|
+
return files.get_first()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test():
|
|
40
|
+
base_dir = Directory("/home/bruno/Downloads/WP/Conversas")
|
|
41
|
+
output_dir = Directory('/home/bruno/Downloads/WP/ORGANIZADO')
|
|
42
|
+
content: ArrayList[Directory] = base_dir.content_dirs(False)
|
|
43
|
+
src_dir: Directory
|
|
44
|
+
|
|
45
|
+
for src_dir in content:
|
|
46
|
+
current_file = get_file_txt(src_dir)
|
|
47
|
+
final_save_dir = output_dir.concat(src_dir.basename(), True)
|
|
48
|
+
|
|
49
|
+
print('=' * 80)
|
|
50
|
+
print(f'Trabalhando em ... {current_file.absolute()}')
|
|
51
|
+
print(f'DESTINO ... {final_save_dir.absolute()}')
|
|
52
|
+
save(current_file, final_save_dir)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def main() -> None:
|
|
58
|
+
from converter import run_ui
|
|
59
|
+
#run_ui()
|
|
60
|
+
test()
|
|
61
|
+
|
|
62
|
+
if __name__ == '__main__':
|
|
63
|
+
main()
|
|
@@ -44,8 +44,8 @@ class NavigatorApp(Navigator):
|
|
|
44
44
|
if self.stack:
|
|
45
45
|
current = self.stack[-1]
|
|
46
46
|
|
|
47
|
-
if current.
|
|
48
|
-
current.
|
|
47
|
+
if current.widget_tk is not None:
|
|
48
|
+
current.widget_tk.pack_forget()
|
|
49
49
|
|
|
50
50
|
element = page.create_element()
|
|
51
51
|
context = BuildContext(self.app, parent_widget=self.app.root)
|
|
@@ -64,8 +64,8 @@ class NavigatorApp(Navigator):
|
|
|
64
64
|
|
|
65
65
|
previous = self.stack[-1]
|
|
66
66
|
|
|
67
|
-
if previous.
|
|
68
|
-
previous.
|
|
67
|
+
if previous.widget_tk is not None:
|
|
68
|
+
previous.widget_tk.pack(fill="both", expand=True)
|
|
69
69
|
|
|
70
70
|
self.current_element = previous
|
|
71
71
|
|
|
@@ -33,18 +33,18 @@ class ExpandedElement(Element):
|
|
|
33
33
|
super().__init__(widget)
|
|
34
34
|
self._child_element: Element | None = None
|
|
35
35
|
|
|
36
|
-
def
|
|
37
|
-
return self.
|
|
36
|
+
def get_widget_flutter(self) -> Expanded:
|
|
37
|
+
return self.widget_flutter
|
|
38
38
|
|
|
39
39
|
def mount(self, context: BuildContext) -> tk.Widget:
|
|
40
40
|
super().mount(context)
|
|
41
|
-
child_element = self.
|
|
42
|
-
child_element.layout_data.flex = self.
|
|
41
|
+
child_element = self.get_widget_flutter().child.create_element()
|
|
42
|
+
child_element.layout_data.flex = self.get_widget_flutter().flex
|
|
43
43
|
child_element.layout_data.expand = True
|
|
44
44
|
widget = child_element.mount(context)
|
|
45
45
|
|
|
46
46
|
self.render_object = child_element.render_object
|
|
47
|
-
self.
|
|
47
|
+
self.widget_tk = widget
|
|
48
48
|
return widget
|
|
49
49
|
|
|
50
50
|
def unmount(self) -> None:
|
|
@@ -68,17 +68,17 @@ class FlexibleElement(ExpandedElement):
|
|
|
68
68
|
def __init__(self, widget: Flexible) -> None:
|
|
69
69
|
super().__init__(widget)
|
|
70
70
|
|
|
71
|
-
def
|
|
72
|
-
return self.
|
|
71
|
+
def get_widget_flutter(self) -> Flexible:
|
|
72
|
+
return self.widget_flutter
|
|
73
73
|
|
|
74
74
|
def mount(self, context: BuildContext) -> tk.Widget:
|
|
75
75
|
super().mount(context)
|
|
76
|
-
child_element = self.
|
|
77
|
-
child_element.layout_data.flex = self.
|
|
76
|
+
child_element = self.get_widget_flutter().child.create_element()
|
|
77
|
+
child_element.layout_data.flex = self.get_widget_flutter().flex
|
|
78
78
|
widget = child_element.mount(context)
|
|
79
79
|
|
|
80
80
|
self.render_object = child_element.render_object
|
|
81
|
-
self.
|
|
81
|
+
self.widget_tk = widget
|
|
82
82
|
return widget
|
|
83
83
|
|
|
84
84
|
|
|
@@ -111,30 +111,30 @@ class ElevatedButtonElement(Element[ttk.Button]):
|
|
|
111
111
|
def __init__(self, widget: ElevatedButton) -> None:
|
|
112
112
|
super().__init__(widget)
|
|
113
113
|
|
|
114
|
-
def
|
|
115
|
-
return self.
|
|
114
|
+
def get_widget_flutter(self) -> ElevatedButton:
|
|
115
|
+
return self.widget_flutter
|
|
116
116
|
|
|
117
|
-
def
|
|
118
|
-
return super().
|
|
117
|
+
def get_widget_tk(self) -> ttk.Button:
|
|
118
|
+
return super().get_widget_tk()
|
|
119
119
|
|
|
120
120
|
def mount(self, context: BuildContext) -> ttk.Button:
|
|
121
121
|
super().mount(context)
|
|
122
|
-
self.
|
|
122
|
+
self.widget_tk = ttk.Button(
|
|
123
123
|
context.parent_tk_widget,
|
|
124
|
-
text=self.
|
|
125
|
-
command=self.
|
|
124
|
+
text=self.get_widget_flutter().text,
|
|
125
|
+
command=self.get_widget_flutter().on_pressed,
|
|
126
126
|
)
|
|
127
127
|
# fill="both" garante que o botão preenche o wrapper
|
|
128
128
|
# que o FlexRenderObject controla via grid
|
|
129
|
-
self.
|
|
130
|
-
return self.
|
|
129
|
+
self.widget_tk.pack(fill="both", expand=True)
|
|
130
|
+
return self.widget_tk
|
|
131
131
|
|
|
132
132
|
def update(self, new_widget: FlutterWidget) -> None:
|
|
133
133
|
super().update(new_widget)
|
|
134
|
-
if self.
|
|
135
|
-
self.
|
|
136
|
-
text=self.
|
|
137
|
-
command=self.
|
|
134
|
+
if self.widget_tk is not None:
|
|
135
|
+
self.get_widget_tk().configure(
|
|
136
|
+
text=self.get_widget_flutter().text,
|
|
137
|
+
command=self.get_widget_flutter().on_pressed,
|
|
138
138
|
)
|
|
139
139
|
|
|
140
140
|
|
|
@@ -176,16 +176,16 @@ class DropdownButtonElement(Element[ttk.Combobox]):
|
|
|
176
176
|
super().__init__(widget)
|
|
177
177
|
self.variable: tk.StringVar = tk.StringVar(value=widget.value)
|
|
178
178
|
|
|
179
|
-
def
|
|
180
|
-
return self.
|
|
179
|
+
def get_widget_flutter(self) -> DropdownButton:
|
|
180
|
+
return self.widget_flutter
|
|
181
181
|
|
|
182
|
-
def
|
|
183
|
-
return super().
|
|
182
|
+
def get_widget_tk(self) -> ttk.Combobox:
|
|
183
|
+
return super().get_widget_tk()
|
|
184
184
|
|
|
185
185
|
def update(self, new_widget: FlutterWidget) -> None:
|
|
186
186
|
super().update(new_widget)
|
|
187
|
-
self.
|
|
188
|
-
self.
|
|
187
|
+
self.get_widget_tk().set(self.get_widget_flutter().value)
|
|
188
|
+
self.get_widget_tk()['values'] = self.get_widget_flutter().items
|
|
189
189
|
|
|
190
190
|
def mount(self, context: BuildContext) -> ttk.Combobox:
|
|
191
191
|
super().mount(context)
|
|
@@ -193,19 +193,19 @@ class DropdownButtonElement(Element[ttk.Combobox]):
|
|
|
193
193
|
combo = ttk.Combobox(
|
|
194
194
|
context.parent_tk_widget,
|
|
195
195
|
textvariable=self.variable,
|
|
196
|
-
values=self.
|
|
196
|
+
values=self.get_widget_flutter().items,
|
|
197
197
|
)
|
|
198
|
-
combo.set(self.
|
|
198
|
+
combo.set(self.get_widget_flutter().value)
|
|
199
199
|
combo.pack(fill="x")
|
|
200
200
|
|
|
201
201
|
# Força o Tk processar o layout antes de setar o valor
|
|
202
202
|
combo.update_idletasks()
|
|
203
203
|
|
|
204
|
-
if self.
|
|
204
|
+
if self.get_widget_flutter().on_changed:
|
|
205
205
|
combo.bind(
|
|
206
|
-
"<<ComboboxSelected>>", lambda e: self.
|
|
206
|
+
"<<ComboboxSelected>>", lambda e: self.get_widget_flutter().on_changed(self.variable.get())
|
|
207
207
|
)
|
|
208
|
-
self.
|
|
208
|
+
self.widget_tk = combo
|
|
209
209
|
return combo
|
|
210
210
|
|
|
211
211
|
|
|
@@ -33,22 +33,22 @@ class SizedBoxElement(Element):
|
|
|
33
33
|
def __init__(self, widget: SizedBox) -> None:
|
|
34
34
|
super().__init__(widget)
|
|
35
35
|
|
|
36
|
-
def
|
|
37
|
-
return self.
|
|
36
|
+
def get_widget_flutter(self) -> SizedBox:
|
|
37
|
+
return self.widget_flutter
|
|
38
38
|
|
|
39
39
|
def mount(self, context: BuildContext) -> tk.Widget:
|
|
40
40
|
|
|
41
41
|
frame = ttk.Frame(context.parent_tk_widget)
|
|
42
42
|
|
|
43
|
-
if self.
|
|
44
|
-
frame.configure(width=self.
|
|
43
|
+
if self.get_widget_flutter().width:
|
|
44
|
+
frame.configure(width=self.get_widget_flutter().width)
|
|
45
45
|
|
|
46
|
-
if self.
|
|
47
|
-
frame.configure(height=self.
|
|
46
|
+
if self.get_widget_flutter().height:
|
|
47
|
+
frame.configure(height=self.get_widget_flutter().height)
|
|
48
48
|
|
|
49
49
|
frame.pack_propagate(False)
|
|
50
50
|
frame.pack()
|
|
51
|
-
self.
|
|
51
|
+
self.widget_tk = frame
|
|
52
52
|
return frame
|
|
53
53
|
|
|
54
54
|
|
|
@@ -84,24 +84,24 @@ class ContainerElement(Element[ttk.Frame]):
|
|
|
84
84
|
def __init__(self, widget: Container) -> None:
|
|
85
85
|
super().__init__(widget)
|
|
86
86
|
|
|
87
|
-
def
|
|
88
|
-
return self.
|
|
87
|
+
def get_widget_flutter(self) -> Container:
|
|
88
|
+
return self.widget_flutter
|
|
89
89
|
|
|
90
90
|
def mount(self, context: BuildContext) -> ttk.Frame:
|
|
91
91
|
super().mount(context)
|
|
92
92
|
|
|
93
93
|
frame = ttk.Frame(context.parent_tk_widget)
|
|
94
94
|
|
|
95
|
-
if self.
|
|
96
|
-
frame.configure(width=float(self.
|
|
95
|
+
if self.get_widget_flutter().width:
|
|
96
|
+
frame.configure(width=float(self.get_widget_flutter().width))
|
|
97
97
|
|
|
98
|
-
if self.
|
|
99
|
-
frame.configure(height=float(self.
|
|
98
|
+
if self.get_widget_flutter().height:
|
|
99
|
+
frame.configure(height=float(self.widget_flutter.height))
|
|
100
100
|
|
|
101
101
|
frame.pack()
|
|
102
102
|
|
|
103
|
-
if self.
|
|
104
|
-
child_element = self.
|
|
103
|
+
if self.get_widget_flutter().child:
|
|
104
|
+
child_element = self.get_widget_flutter().child.create_element()
|
|
105
105
|
|
|
106
106
|
child_context = (
|
|
107
107
|
BuildContext(
|
|
@@ -115,5 +115,5 @@ class ContainerElement(Element[ttk.Frame]):
|
|
|
115
115
|
child_context
|
|
116
116
|
)
|
|
117
117
|
|
|
118
|
-
self.
|
|
118
|
+
self.widget_tk = frame
|
|
119
119
|
return frame
|