1818from gerenciador_excecoes import gerenciador_excecoes , TipoErro , GerenciadorExcecoes # import exception handler
1919from utilidades_ui import GerenciadorResponsividade , UtiliadadesGraficos # import UI utilities
2020from lugar_geometrico_raizes import AnalisadorLGR , ErroValidacaoLGR
21+ from tema_config import GerenciadorTemas , gerenciador_temas
22+
23+ CORES = gerenciador_temas .obter_cores ()
24+
25+ # Configuração do tema inicial
26+ ctk .set_appearance_mode (CORES ["mode" ])
27+ ctk .set_default_color_theme ("blue" )
28+
2129
2230class GerenciadorTemas :
2331 """Gerencia temas claro e escuro com persistência"""
@@ -533,8 +541,8 @@ def configurar_atalhos(self):
533541 self .bind ("<Alt-F4>" , lambda e : self ._on_closing ())
534542
535543 # Atalhos de teclado para acessibilidade
536- self .bind ("<Control-plus>" , lambda e : self .aumentar_fonte ())
537- self .bind ("<Control-minus>" , lambda e : self .diminuir_fonte ())
544+ self .bind ("<Control-plus>" , lambda e : self .aumentar_fonte_global ())
545+ self .bind ("<Control-minus>" , lambda e : self .diminuir_fonte_global ())
538546 self .bind ("<Control-t>" , lambda e : self .alternar_tema ())
539547 self .bind ("<Control-h>" , lambda e : self .mostrar_ajuda ())
540548 self .bind ("<Control-c>" , lambda e : self .toggle_alto_contraste ())
@@ -826,7 +834,7 @@ def mostrar_painel_configuracoes(self):
826834 ctk .CTkButton (
827835 frame_acess ,
828836 text = "🔤 Aumentar Fonte (Ctrl++)" ,
829- command = self .aumentar_fonte ,
837+ command = self .aumentar_fonte_global ,
830838 width = 250 ,
831839 height = 40 ,
832840 font = ("Segoe UI" , self .scale_font (14 ), "bold" ),
@@ -837,7 +845,7 @@ def mostrar_painel_configuracoes(self):
837845 ctk .CTkButton (
838846 frame_acess ,
839847 text = "🔡 Diminuir Fonte (Ctrl+-)" ,
840- command = self .diminuir_fonte ,
848+ command = self .diminuir_fonte_global ,
841849 width = 250 ,
842850 height = 40 ,
843851 font = ("Segoe UI" , self .scale_font (14 ), "bold" ),
@@ -913,34 +921,45 @@ def toggle_alto_contraste(self):
913921 else :
914922 self .aplicar_tema ("high_contrast" )
915923
916- def aumentar_fonte (self ):
917- """Aumenta o tamanho das fontes do sistema"""
918- # Obtem o tamanho atual e adiciona um valor fixo ou proporcional
924+ def aumentar_fonte_global (self ):
925+ """Aumenta o tamanho das fontes do sistema em todos os frames ativos """
926+ # Ajusta o tamanho base das fontes
919927 if self .font_corpo .cget ("size" ) < 20 : # Limite para evitar fontes gigantes
920928 self .font_titulo .configure (size = self .font_titulo .cget ("size" ) + 2 )
921929 self .font_subtitulo .configure (size = self .font_subtitulo .cget ("size" ) + 2 )
922930 self .font_corpo .configure (size = self .font_corpo .cget ("size" ) + 1 )
923931 self .font_label .configure (size = self .font_label .cget ("size" ) + 1 )
924932 self .font_pequeno .configure (size = self .font_pequeno .cget ("size" ) + 1 )
925- logger .info ("Fontes aumentadas" )
933+
934+ # Atualiza fontes em módulos abertos
935+ for widget in self .winfo_children ():
936+ if isinstance (widget , FrameBase ):
937+ widget .atualizar_fontes ()
938+
939+ logger .info ("Fontes aumentadas globalmente" )
926940
927- def diminuir_fonte (self ):
928- """Diminui o tamanho das fontes do sistema"""
929- # Obtem o tamanho atual e subtrai um valor fixo ou proporcional
941+ def diminuir_fonte_global (self ):
942+ """Diminui o tamanho das fontes do sistema em todos os frames ativos"""
930943 if self .font_corpo .cget ("size" ) > 10 : # Limite para evitar fontes muito pequenas
931944 self .font_titulo .configure (size = self .font_titulo .cget ("size" ) - 2 )
932945 self .font_subtitulo .configure (size = self .font_subtitulo .cget ("size" ) - 2 )
933946 self .font_corpo .configure (size = self .font_corpo .cget ("size" ) - 1 )
934947 self .font_label .configure (size = self .font_label .cget ("size" ) - 1 )
935948 self .font_pequeno .configure (size = self .font_pequeno .cget ("size" ) - 1 )
936- logger .info ("Fontes diminuídas" )
949+
950+ # Atualiza fontes em módulos abertos
951+ for widget in self .winfo_children ():
952+ if isinstance (widget , FrameBase ):
953+ widget .atualizar_fontes ()
954+
955+ logger .info ("Fontes diminuídas globalmente" )
937956
938957 def resetar_fonte (self ):
939958 """Reseta as fontes para o tamanho padrão"""
940959 self .font_titulo .configure (size = 20 )
941960 self .font_subtitulo .configure (size = 16 )
942961 self .font_corpo .configure (size = 14 )
943- self .font_label .configure (size = 10 )
962+ self .font_label .configure (size = 12 )
944963 self .font_pequeno .configure (size = 10 )
945964 logger .info ("Fontes resetadas" )
946965
@@ -1071,7 +1090,7 @@ def mostrar_erro(self, mensagem):
10711090 text_color = CORES ["erro" ]
10721091 ).pack (pady = (20 , 10 ))
10731092
1074- ctk .CTkTextbox (
1093+ erro_textbox = ctk .CTkTextbox (
10751094 janela_erro ,
10761095 font = self .font_corpo ,
10771096 text_color = CORES ["texto_principal" ],
@@ -1080,11 +1099,10 @@ def mostrar_erro(self, mensagem):
10801099 height = 100 ,
10811100 wrap = "word" ,
10821101 activate_scrollbars = True
1083- ).pack (pady = 10 , padx = 20 , fill = "both" , expand = True )
1084-
1085- # Insere a mensagem no Textbox (que acabamos de criar)
1086- janela_erro .winfo_children ()[- 1 ].insert ("1.0" , mensagem )
1087- janela_erro .winfo_children ()[- 1 ].configure (state = "disabled" )
1102+ )
1103+ erro_textbox .pack (pady = 10 , padx = 20 , fill = "both" , expand = True )
1104+ erro_textbox .insert ("1.0" , mensagem )
1105+ erro_textbox .configure (state = "disabled" )
10881106
10891107 ctk .CTkButton (
10901108 janela_erro ,
@@ -1121,6 +1139,11 @@ def recriar_interface(self):
11211139 # Fechar painel de configurações se estiver aberto
11221140 if self .config_visivel :
11231141 self .toggle_configuracoes ()
1142+
1143+ # Atualizar fontes dos frames de módulos abertos
1144+ for widget in self .winfo_children ():
1145+ if isinstance (widget , FrameBase ):
1146+ widget .atualizar_fontes ()
11241147
11251148 def trocar_para_frame (self , frame_class , * args , ** kwargs ):
11261149 """
@@ -1143,14 +1166,13 @@ def trocar_para_frame(self, frame_class, *args, **kwargs):
11431166 self .frame_atual .grid (row = 0 , column = 0 , sticky = "nsew" )
11441167
11451168 # Fade in
1146- self .after (50 )
1147- self .attributes ("-alpha" , 1.0 )
1169+ self .after (50 , lambda : self .attributes ("-alpha" , 1.0 )) # Usar lambda para garantir execução assíncrona
11481170
11491171 def voltar_para_menu (self ):
11501172 """Volta para o menu principal com transição"""
11511173 self .trocar_para_frame (TelaPrincipal )
11521174
1153- # Aumentar e diminuir fonte já foram refatorados acima em SistemaTCC
1175+ # Métodos de fonte globais já definidos em aumentar_fonte_global e diminuir_fonte_global
11541176
11551177 # Este método abrir_janela foi atualizado acima, removendo a lógica "lgr"
11561178 # def abrir_janela(self, tipo_janela, titulo): ...
@@ -1453,6 +1475,11 @@ def voltar_menu(self):
14531475 """Volta para o menu principal"""
14541476 self .controlador .voltar_para_menu ()
14551477
1478+ def atualizar_fontes (self ):
1479+ """Atualiza fontes dos widgets deste frame (se necessário)"""
1480+ # Exemplo: Se houver labels, botões, etc. com fontes específicas
1481+ pass # Deve ser implementado nas subclasses se necessário
1482+
14561483class FrameCriterio (FrameBase ):
14571484 def __init__ (self , parent , controlador , titulo ):
14581485 self .numerador = []
@@ -2240,7 +2267,7 @@ def plotar_grafico(self):
22402267 self .canvas_grafico .draw ()
22412268
22422269 canvas_widget = self .canvas_grafico .get_tk_widget ()
2243- canvas_widget .grid (row = 0 , column = 0 , sticky = "nsew" , padx = 0 , pady = 0 )
2270+ canvas_widget .grid (row = 0 , column = 0 , sticky = "nsew" )
22442271 canvas_widget .grid_propagate (True )
22452272
22462273 toolbar_frame = ctk .CTkFrame (self .grafico_container , fg_color = "transparent" )
@@ -2272,11 +2299,6 @@ def mostrar_erro(self, mensagem):
22722299 self .texto_resultados .insert ("end" , "• Denominador: 1 2 4\n " )
22732300 self .texto_resultados .insert ("end" , " (representa: G(s) = 4 / (s² + 2s + 4))\n " )
22742301
2275-
2276- # ==================================================================
2277- # ================== CLASSE JANELALGR ATUALIZADA ===================
2278- # ==================================================================
2279-
22802302class JanelaLGR (FrameBase ):
22812303 """Frame para análise do Lugar Geométrico das Raízes (agora herda de FrameBase)"""
22822304
0 commit comments