before frames update

This commit is contained in:
2024-07-14 19:50:15 +02:00
parent d7b8f65627
commit 13bcc98cac
9 changed files with 400 additions and 330 deletions

73
main.py
View File

@@ -2,14 +2,12 @@
Main module for the Image Processor application.
"""
import tkinter as tk
from tkinter import ttk
import customtkinter
import customtkinter as ctk
from ui.log_window import LogWindow
from ui.local_processing_tab import LocalProcessingTab
from ui.settings_tab import SettingsTab
from config.decrypt_config import ConfigDecryptor, DECRYPTION_KEY
from config.encrypt_config import ConfigEncryptor
class ImageProcessorApp:
"""
@@ -21,42 +19,69 @@ class ImageProcessorApp:
Initialize the ImageProcessorApp.
Args:
root (tk.Tk): The root Tkinter window.
root (ctk.CTk): The root CustomTkinter window.
"""
self.root = root
self.root.title("Image Processor")
self.root.geometry("500x450")
self.root.geometry("520x600")
self.tab_parent = ttk.Notebook(self.root)
self.log_window = None
# Create menu frame at the top
menu_frame = ctk.CTkFrame(self.root)
menu_frame.pack(side="top", fill="x")
self.local_processing_tab = LocalProcessingTab(
self.tab_parent, "Local Processing", self.open_log_window
)
self.settings_tab = SettingsTab(self.tab_parent, "Settings")
local_processing_button = ctk.CTkButton(menu_frame, text="Local Processing", command=self.show_local_processing_tab)
local_processing_button.pack(side="left", padx=5, pady=5)
self.tab_parent.pack(expand=True, fill="both")
settings_button = ctk.CTkButton(menu_frame, text="Settings", command=self.show_settings_tab)
settings_button.pack(side="left", padx=5, pady=5)
def open_log_window(self):
# Create main frame to hold tabs and log window
main_frame = ctk.CTkFrame(self.root)
main_frame.pack(expand=True, fill="both")
self.tab_parent = ctk.CTkFrame(main_frame)
self.tab_parent.grid(row=0, column=0, sticky="nsew")
self.log_frame = ctk.CTkFrame(main_frame)
self.log_frame.grid(row=1, column=0, sticky="nsew")
main_frame.grid_rowconfigure(0, weight=3)
main_frame.grid_rowconfigure(1, weight=1)
main_frame.grid_columnconfigure(0, weight=1)
self.log_window = LogWindow(self.log_frame)
self.local_processing_tab = LocalProcessingTab(self.tab_parent, self.log_window)
self.settings_tab = SettingsTab(self.tab_parent)
self.local_processing_tab.tab.grid(row=0, column=0, sticky="nsew")
self.settings_tab.tab.grid(row=0, column=0, sticky="nsew")
self.show_local_processing_tab()
def show_local_processing_tab(self):
"""
Open the log window. If it already exists, bring it to the front.
Show the Local Processing tab.
"""
if self.log_window is None or not self.log_window.winfo_exists():
self.log_window = LogWindow(self.root)
else:
self.log_window.lift()
self.local_processing_tab.tab.tkraise()
def show_settings_tab(self):
"""
Show the Settings tab.
"""
self.settings_tab.tab.tkraise()
def run(self):
"""
Run the Tkinter main loop.
Run the CustomTkinter main loop.
"""
self.root.mainloop()
if __name__ == "__main__":
try:
decryptor = ConfigDecryptor(DECRYPTION_KEY)
config = decryptor.decrypt()
decryptor = ConfigEncryptor(DECRYPTION_KEY)
config = decryptor.load_config()
wc_url = config["url"]
wc_consumer_key = config["consumer_key"]
wc_consumer_secret = config["consumer_secret"]
@@ -65,6 +90,8 @@ if __name__ == "__main__":
except FileNotFoundError as e:
print(f"File not found: {e}")
root = customtkinter.CTk()
root = ctk.CTk()
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")
app = ImageProcessorApp(root)
app.run()