-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtab_functions.py
197 lines (164 loc) · 6.6 KB
/
tab_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
from pathlib import Path
from tkinter import messagebox, ttk
def abrir_aba_leitura(
notebook: ttk.Notebook,
imagens_dict: dict[str, dict],
id_reuniao: int,
local_de_salvamento: Path,
):
from Telas.Leitura.leitura import criar_tela_leitura
frame_leitura = ttk.Frame(
notebook, width=notebook.winfo_width(), height=notebook.winfo_height()
)
frame_leitura.pack(fill="both", expand=True)
criar_tela_leitura(
frame_leitura,
imagens_dict["Leitura"],
notebook,
imagens_dict,
id_reuniao,
local_de_salvamento,
)
notebook.insert(0, frame_leitura, text="Leitura") # Insere na primeira posição
notebook.select(frame_leitura)
def abrir_aba_consultar_rg(notebook: ttk.Notebook, imagens_dict: dict[str, dict]):
from Telas.ConsultarRG.buscarReuniao import criar_tela_buscar_rg
frame_buscar_rg = ttk.Frame(
notebook, width=notebook.winfo_width(), height=notebook.winfo_height()
)
frame_buscar_rg.pack(fill="both", expand=True)
criar_tela_buscar_rg(
frame_buscar_rg,
imagens_dict["ConsultarRG"],
notebook,
imagens_dict,
)
notebook.add(frame_buscar_rg, text="Consultar RG")
def abrir_aba_consultar_usuarios(notebook: ttk.Notebook, imagens_dict: dict[str, dict]):
from Telas.ConsultarUsuários.consultar import criar_tela_consultar_usuarios
frame_consultar_usuario = ttk.Frame(
notebook, width=notebook.winfo_width(), height=notebook.winfo_height()
)
frame_consultar_usuario.pack(fill="both", expand=True)
criar_tela_consultar_usuarios(
frame_consultar_usuario,
imagens_dict["ConsultarUsuarios"],
notebook,
imagens_dict,
)
notebook.add(frame_consultar_usuario, text="Consultar Usuários")
def abrir_aba_cadastrar_usuario(notebook: ttk.Notebook, imagens_dict: dict[str, dict]):
from Telas.CadastroUsuário.cadastro import criar_tela_cadastro_usuarios
frame_cadastrar_usuario = ttk.Frame(
notebook, width=notebook.winfo_width(), height=notebook.winfo_height()
)
frame_cadastrar_usuario.pack(fill="both", expand=True)
criar_tela_cadastro_usuarios(
frame_cadastrar_usuario, imagens_dict["CadastroUsuario"]
)
notebook.add(frame_cadastrar_usuario, text="Cadastrar Usuário")
def abrir_aba_exportar(notebook: ttk.Notebook, imagens_dict: dict[str, dict]):
from Telas.ExportarRG.exportar import criar_tela_exportar
frame_exportar = ttk.Frame(
notebook, width=notebook.winfo_width(), height=notebook.winfo_height()
)
frame_exportar.pack(fill="both", expand=True)
criar_tela_exportar(frame_exportar, imagens_dict["Exportar"])
notebook.add(frame_exportar, text="Exportar")
def abrir_aba_editar_usuario(
notebook: ttk.Notebook,
imagens_dict: dict[str, dict],
id: str,
):
from Telas.EditarUsuários.editarUser import criar_tela_edicao_usuarios
if id == "":
messagebox.showerror(
"Nenhum Usuário Selecionado", "Nenhum usuário foi selecionado na tabela"
)
return
frame_editar_usuario = ttk.Frame(
notebook, width=notebook.winfo_width(), height=notebook.winfo_height()
)
frame_editar_usuario.pack(fill="both", expand=True)
criar_tela_edicao_usuarios(
frame_editar_usuario, imagens_dict["EditarUsuario"], int(id)
)
notebook.add(frame_editar_usuario, text="Editar Usuário")
notebook.select(frame_editar_usuario)
notebook.bind(
"<<NotebookTabChanged>>",
lambda event: fechar_aba_ao_sair(notebook, frame_editar_usuario),
add="+",
)
def abrir_aba_editar_rg(
notebook: ttk.Notebook,
imagens_dict: dict[str, dict],
id: str,
):
from Telas.EditarRG.editar import criar_tela_editar_rg
if id == "":
messagebox.showerror(
"Nenhuma Reunião Selecionada", "Nenhuma reunião foi selecionada na tabela"
)
return
frame_editar_rg = ttk.Frame(
notebook, width=notebook.winfo_width(), height=notebook.winfo_height()
)
frame_editar_rg.pack(fill="both", expand=True)
criar_tela_editar_rg(frame_editar_rg, imagens_dict["EditarRG"], int(id), notebook)
notebook.add(frame_editar_rg, text="Editar RG")
notebook.select(frame_editar_rg)
notebook.bind(
"<<NotebookTabChanged>>",
lambda event: fechar_aba_ao_sair(notebook, frame_editar_rg),
add="+",
)
def abrir_aba_comecar_rg(notebook: ttk.Notebook, imagens_dict: dict[str, dict]):
from Telas.ComeçarRG.começar import criar_tela_comecar_rg
frame_comecar_rg = ttk.Frame(
notebook, width=notebook.winfo_width(), height=notebook.winfo_height()
)
frame_comecar_rg.pack(fill="both", expand=True)
criar_tela_comecar_rg(
frame_comecar_rg, imagens_dict["ComecarRG"], notebook, imagens_dict
)
if notebook.index("end") == 0:
# Não existe nenhuma aba
notebook.add(frame_comecar_rg, text="Começar RG")
else:
# Existe outra aba aberta então adicionamos no começo
notebook.insert(0, frame_comecar_rg, text="Começar RG")
notebook.select(frame_comecar_rg)
def fechar_aba_ao_sair(notebook: ttk.Notebook, frame: ttk.Frame):
if notebook.index("current") != notebook.index(frame):
notebook.unbind("<<NotebookTabChanged>>")
notebook.bind(
"<<NotebookTabChanged>>", lambda event: ao_trocar_aba(event, notebook)
)
notebook.forget(frame)
def atualizar_aba(aba_selecionada: str, frame_aba: ttk.Frame):
frame_aba.focus_set()
if aba_selecionada == "Consultar RG":
frame_aba.event_generate("<F5>")
print(f"Atualizando {aba_selecionada}")
elif aba_selecionada == "Consultar Usuários":
frame_aba.event_generate("<F5>")
print(f"Atualizando {aba_selecionada}")
elif aba_selecionada == "Exportar":
frame_aba.event_generate("<F5>")
print(f"Atualizando {aba_selecionada}")
elif aba_selecionada == "Editar Usuário":
frame_aba.event_generate("<F5>")
print(f"Atualizando {aba_selecionada}")
elif aba_selecionada == "Editar RG":
frame_aba.event_generate("<F5>")
print(f"Atualizando {aba_selecionada}")
def ao_trocar_aba(event, notebook: ttk.Notebook):
aba_selecionada = notebook.tab(notebook.select(), "text")
frame_aba = notebook.nametowidget(notebook.select())
atualizar_aba(aba_selecionada, frame_aba)
def selecionar_aba_por_nome(notebook: ttk.Notebook, nome_da_aba: str):
for indice_aba in range(notebook.index('end')):
if notebook.tab(indice_aba, "text") == nome_da_aba:
notebook.select(indice_aba)
break