From f30490a67695b42d1be47915c3eebbb449114c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ruthotto?= Date: Tue, 3 Sep 2024 08:50:26 +0200 Subject: [PATCH] add Controller --- src/controller/mainFrameController.py | 10 + src/main.py | 3 + src/models/data.py | 11 + src/utils/webTextExtractor.py | 3 + src/views/mainScreen.py | 33 ++- theme.json | 359 ++++++++++++++++++++++++++ 6 files changed, 402 insertions(+), 17 deletions(-) create mode 100644 src/controller/mainFrameController.py create mode 100644 src/models/data.py create mode 100644 theme.json diff --git a/src/controller/mainFrameController.py b/src/controller/mainFrameController.py new file mode 100644 index 0000000..a69b0ac --- /dev/null +++ b/src/controller/mainFrameController.py @@ -0,0 +1,10 @@ +from views.mainScreen import MainFrame +from models.data import TextData +class MainFrameController: + + def __init__(self,frame:MainFrame) -> None: + self.frame = frame + self.text_data = TextData() + + def get_entry(self): + self.text_data.url = self.frame.entry_url.get() \ No newline at end of file diff --git a/src/main.py b/src/main.py index 1f70e89..3fb2e4d 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,6 @@ import customtkinter from views.mainScreen import MainFrame +from controller.mainFrameController import MainFrameController class Main(customtkinter.CTk): def __init__(self) -> None: @@ -10,12 +11,14 @@ class Main(customtkinter.CTk): mainFrame = MainFrame(self) mainFrame.grid(row=0, column=0, padx=10, pady=10,sticky="nsew") + controller_mainframe = MainFrameController(mainFrame) self.title("VeracityAI") self.geometry("800x500") if __name__ == "__main__": customtkinter.deactivate_automatic_dpi_awareness() + customtkinter.set_default_color_theme('theme.json') customtkinter.set_appearance_mode("dark") app = Main() app.mainloop() \ No newline at end of file diff --git a/src/models/data.py b/src/models/data.py new file mode 100644 index 0000000..ffe5a5f --- /dev/null +++ b/src/models/data.py @@ -0,0 +1,11 @@ +from utils.webTextExtractor import WebTextExtractor + +class TextData: + def __init__(self) -> None: + self.url = "" + self.text = "" + + def text_from_url(self): + if self.url is not "" and self.text == "": + extractor = WebTextExtractor(self.url) + self.text = extractor.get_text() \ No newline at end of file diff --git a/src/utils/webTextExtractor.py b/src/utils/webTextExtractor.py index aa94d31..33fb776 100644 --- a/src/utils/webTextExtractor.py +++ b/src/utils/webTextExtractor.py @@ -6,6 +6,9 @@ class WebTextExtractor: self.url = url self.content = None self.text = None + + self.fetch_content() + self.extract_text() def fetch_content(self): """Holt den HTML-Inhalt von der Webseite.""" diff --git a/src/views/mainScreen.py b/src/views/mainScreen.py index b967203..1c80f41 100644 --- a/src/views/mainScreen.py +++ b/src/views/mainScreen.py @@ -1,6 +1,5 @@ from typing import Any import customtkinter as ctk - class MainFrame(ctk.CTkFrame): def __init__(self, master: Any, **kwargs): @@ -13,28 +12,28 @@ class MainFrame(ctk.CTkFrame): self.grid_columnconfigure(2, weight=1) # Rechte Spalte soll sich dehnen # Linkes Frame - frame1 = ctk.CTkFrame(self) - frame1.grid(row=0, column=0, sticky="nsew", padx=10, pady=10) - frame1.grid_rowconfigure(2, weight=1) # Lasse die Output-Textbox wachsen - frame1.grid_columnconfigure(0, weight=1) # Lasse frame1 horizontal wachsen + self.frame1 = ctk.CTkFrame(self) + self.frame1.grid(row=0, column=0, sticky="nsew", padx=10, pady=10) + self.frame1.grid_rowconfigure(2, weight=1) # Lasse die Output-Textbox wachsen + self.frame1.grid_columnconfigure(0, weight=1) # Lasse frame1 horizontal wachsen - entry_url = ctk.CTkEntry(frame1, placeholder_text='Web link to article', height=50) - entry_url.grid(row=0, column=0, padx=10, pady=10, sticky="ew") + self.entry_url = ctk.CTkEntry(self.frame1, placeholder_text='Web link to article', height=50) + self.entry_url.grid(row=0, column=0, padx=10, pady=10, sticky="ew") - input_textbox = ctk.CTkTextbox(frame1, height=200) - input_textbox.grid(row=1, column=0, padx=10, pady=10, sticky="nsew") + self.input_textbox = ctk.CTkTextbox(self.frame1, height=200) + self.input_textbox.grid(row=1, column=0, padx=10, pady=10, sticky="nsew") - output_textbox = ctk.CTkTextbox(frame1, height=150, state="disabled") - output_textbox.grid(row=2, column=0, padx=10, pady=10, sticky="nsew") + self.output_textbox = ctk.CTkTextbox(self.frame1, height=150, state="disabled") + self.output_textbox.grid(row=2, column=0, padx=10, pady=10, sticky="nsew") # Mittlerer Button - check_button = ctk.CTkButton(self, text="Check", width=60, height=300, fg_color="green") - check_button.grid(row=0, column=1, padx=10, pady=10, sticky="nsew") + self.check_button = ctk.CTkButton(self, text="Check", width=60, height=300) + self.check_button.grid(row=0, column=1, padx=10, pady=10, sticky="nsew") # Rechte scrollbare Ansicht - scrollview = ctk.CTkScrollableFrame(self) - scrollview.grid(row=0, column=2, padx=10, pady=10, sticky="nsew") + self.scrollview = ctk.CTkScrollableFrame(self) + self.scrollview.grid(row=0, column=2, padx=10, pady=10, sticky="nsew") # Überschrift hinzufügen - header = ctk.CTkLabel(scrollview, text="Leaderboard", font=("Arial", 24, "bold")) - header.pack(pady=10, padx=10, anchor="w") \ No newline at end of file + self.header = ctk.CTkLabel(self.scrollview, text="Leaderboard", font=("Arial", 24, "bold")) + self.header.pack(pady=10, padx=10, anchor="w") \ No newline at end of file diff --git a/theme.json b/theme.json new file mode 100644 index 0000000..d8463c7 --- /dev/null +++ b/theme.json @@ -0,0 +1,359 @@ +{ + "CTk": { + "fg_color": [ + "gray92", + "gray14" + ] + }, + "CTkToplevel": { + "fg_color": [ + "gray92", + "gray14" + ] + }, + "CTkFrame": { + "corner_radius": 6, + "border_width": 0, + "fg_color": [ + "gray86", + "gray17" + ], + "top_fg_color": [ + "gray81", + "gray20" + ], + "border_color": [ + "gray65", + "gray28" + ] + }, + "CTkButton": { + "corner_radius": 6, + "border_width": 0, + "fg_color": [ + "#80ffff", + "#008080" + ], + "hover_color": [ + "#80ffff", + "#00bfbf" + ], + "border_color": [ + "#3E454A", + "#949A9F" + ], + "text_color": [ + "#DCE4EE", + "#DCE4EE" + ], + "text_color_disabled": [ + "gray74", + "gray60" + ] + }, + "CTkLabel": { + "corner_radius": 0, + "fg_color": "transparent", + "text_color": [ + "gray10", + "#DCE4EE" + ] + }, + "CTkEntry": { + "corner_radius": 6, + "border_width": 2, + "fg_color": [ + "#F9F9FA", + "#343638" + ], + "border_color": [ + "#979DA2", + "#565B5E" + ], + "text_color": [ + "gray10", + "#DCE4EE" + ], + "placeholder_text_color": [ + "gray52", + "gray62" + ] + }, + "CTkCheckBox": { + "corner_radius": 6, + "border_width": 3, + "fg_color": [ + "#80ffff", + "#008080" + ], + "border_color": [ + "#3E454A", + "#949A9F" + ], + "hover_color": [ + "#00ffff", + "#009595" + ], + "checkmark_color": [ + "#DCE4EE", + "gray90" + ], + "text_color": [ + "gray10", + "#DCE4EE" + ], + "text_color_disabled": [ + "gray60", + "gray45" + ] + }, + "CTkSwitch": { + "corner_radius": 1000, + "border_width": 3, + "button_length": 0, + "fg_color": [ + "#939BA2", + "#4A4D50" + ], + "progress_color": [ + "#55ffff", + "#00bfbf" + ], + "button_color": [ + "gray36", + "#D5D9DE" + ], + "button_hover_color": [ + "gray20", + "gray100" + ], + "text_color": [ + "gray10", + "#DCE4EE" + ], + "text_color_disabled": [ + "gray60", + "gray45" + ] + }, + "CTkRadioButton": { + "corner_radius": 1000, + "border_width_checked": 6, + "border_width_unchecked": 3, + "fg_color": [ + "#80ffff", + "#008080" + ], + "border_color": [ + "#3E454A", + "#949A9F" + ], + "hover_color": [ + "#36719F", + "#144870" + ], + "text_color": [ + "gray10", + "#DCE4EE" + ], + "text_color_disabled": [ + "gray60", + "gray45" + ] + }, + "CTkProgressBar": { + "corner_radius": 1000, + "border_width": 0, + "fg_color": [ + "#939BA2", + "#4A4D50" + ], + "progress_color": [ + "#80ffff", + "#008080" + ], + "border_color": [ + "gray", + "gray" + ] + }, + "CTkSlider": { + "corner_radius": 1000, + "button_corner_radius": 1000, + "border_width": 6, + "button_length": 0, + "fg_color": [ + "#939BA2", + "#4A4D50" + ], + "progress_color": [ + "gray40", + "#AAB0B5" + ], + "button_color": [ + "#80ffff", + "#008080" + ], + "button_hover_color": [ + "#55ffff", + "#00bfbf" + ] + }, + "CTkOptionMenu": { + "corner_radius": 6, + "fg_color": [ + "#80ffff", + "#008080" + ], + "button_color": [ + "#80ffff", + "#006a6a" + ], + "button_hover_color": [ + "#80ffff", + "#00bfbf" + ], + "text_color": [ + "#DCE4EE", + "#DCE4EE" + ], + "text_color_disabled": [ + "gray74", + "gray60" + ] + }, + "CTkComboBox": { + "corner_radius": 6, + "border_width": 2, + "fg_color": [ + "#F9F9FA", + "#343638" + ], + "border_color": [ + "#979DA2", + "#565B5E" + ], + "button_color": [ + "#979DA2", + "#565B5E" + ], + "button_hover_color": [ + "#6E7174", + "#7A848D" + ], + "text_color": [ + "gray10", + "#DCE4EE" + ], + "text_color_disabled": [ + "gray50", + "gray45" + ] + }, + "CTkScrollbar": { + "corner_radius": 1000, + "border_spacing": 4, + "fg_color": "transparent", + "button_color": [ + "gray55", + "gray41" + ], + "button_hover_color": [ + "gray40", + "gray53" + ] + }, + "CTkSegmentedButton": { + "corner_radius": 6, + "border_width": 2, + "fg_color": [ + "#979DA2", + "gray29" + ], + "selected_color": [ + "#80ffff", + "#008080" + ], + "selected_hover_color": [ + "#80ffff", + "#00bfbf" + ], + "unselected_color": [ + "#979DA2", + "gray29" + ], + "unselected_hover_color": [ + "gray70", + "gray41" + ], + "text_color": [ + "#DCE4EE", + "#DCE4EE" + ], + "text_color_disabled": [ + "gray74", + "gray60" + ] + }, + "CTkTextbox": { + "corner_radius": 6, + "border_width": 0, + "fg_color": [ + "#F9F9FA", + "#1D1E1E" + ], + "border_color": [ + "#979DA2", + "#565B5E" + ], + "text_color": [ + "gray10", + "#DCE4EE" + ], + "scrollbar_button_color": [ + "gray55", + "gray41" + ], + "scrollbar_button_hover_color": [ + "gray40", + "gray53" + ] + }, + "CTkScrollableFrame": { + "label_fg_color": [ + "gray78", + "gray23" + ] + }, + "DropdownMenu": { + "fg_color": [ + "gray90", + "gray20" + ], + "hover_color": [ + "gray75", + "gray28" + ], + "text_color": [ + "gray10", + "gray90" + ] + }, + "CTkFont": { + "macOS": { + "family": "SF Display", + "size": 13, + "weight": "normal" + }, + "Windows": { + "family": "Roboto", + "size": 13, + "weight": "normal" + }, + "Linux": { + "family": "Roboto", + "size": 13, + "weight": "normal" + } + } +} \ No newline at end of file