Merge pull request 'feat/firstGUI' (#12) from feat/firstGUI into develop
Reviewed-on: #12
This commit is contained in:
commit
8e6a249628
|
@ -0,0 +1,21 @@
|
|||
from views.mainScreen import MainFrame
|
||||
from models.data import TextData
|
||||
class MainFrameController:
|
||||
|
||||
def __init__(self,frame:MainFrame) -> None:
|
||||
self.frame = frame
|
||||
|
||||
|
||||
def get_textdata(self) -> TextData:
|
||||
text_data = TextData()
|
||||
text_data.url = self.frame.entry_url.get()
|
||||
if text_data.text_from_url():
|
||||
text_data.text = self.frame.input_textbox.get("0.0", "end")
|
||||
|
||||
return text_data
|
||||
|
||||
def press_check_button(self):
|
||||
text_data = self.get_textdata()
|
||||
print(f"text:{text_data.text}")
|
||||
|
||||
|
26
src/main.py
26
src/main.py
|
@ -0,0 +1,26 @@
|
|||
import customtkinter
|
||||
from views.mainScreen import MainFrame
|
||||
from controller.mainFrameController import MainFrameController
|
||||
class Main(customtkinter.CTk):
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
# Grid-Konfiguration, um das Frame an die Größe anzupassen
|
||||
self.grid_rowconfigure(0, weight=1)
|
||||
self.grid_columnconfigure(0, weight=1)
|
||||
|
||||
mainFrame = MainFrame(self)
|
||||
mainFrame.grid(row=0, column=0, padx=10, pady=10,sticky="nsew")
|
||||
controller_mainframe = MainFrameController(mainFrame)
|
||||
mainFrame.set_controller(controller_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()
|
|
@ -0,0 +1,28 @@
|
|||
from utils.webTextExtractor import WebTextExtractor
|
||||
|
||||
class TextData:
|
||||
def __init__(self, url: str = "") -> None:
|
||||
self.url = url
|
||||
self.text = ""
|
||||
self._extractor = None
|
||||
|
||||
def set_url(self, url: str) -> None:
|
||||
self.url = url
|
||||
self.text = "" # Reset text when URL changes
|
||||
self._extractor = None # Reset extractor when URL changes
|
||||
|
||||
def text_from_url(self)-> bool:
|
||||
if not self.url:
|
||||
print("No url")
|
||||
return True
|
||||
|
||||
if not self.text:
|
||||
print("Extrahiere Text von URL...")
|
||||
self._extractor = WebTextExtractor(self.url)
|
||||
self._extractor.fetch_content()
|
||||
self._extractor.extract_text()
|
||||
self.text = self._extractor.get_text()
|
||||
return False
|
||||
|
||||
|
||||
|
|
@ -28,20 +28,9 @@ class WebTextExtractor:
|
|||
def get_text(self):
|
||||
"""Gibt den extrahierten Text zurück."""
|
||||
if self.text:
|
||||
return self.text
|
||||
return self.text
|
||||
else:
|
||||
raise Exception("Kein Text extrahiert. Bitte zuerst extract_text() aufrufen.")
|
||||
|
||||
|
||||
# Beispielaufruf
|
||||
if __name__ == "__main__":
|
||||
url = "https://de.wikipedia.org/wiki/Lineare_Algebra"
|
||||
extractor = WebTextExtractor(url)
|
||||
|
||||
# HTML-Inhalt abrufen
|
||||
extractor.fetch_content()
|
||||
|
||||
# Text extrahieren
|
||||
extractor.extract_text()
|
||||
|
||||
print(extractor.get_text())
|
|
@ -0,0 +1,46 @@
|
|||
from typing import Any
|
||||
import customtkinter as ctk
|
||||
class MainFrame(ctk.CTkFrame):
|
||||
|
||||
def __init__(self, master: Any, **kwargs):
|
||||
super().__init__(master, **kwargs)
|
||||
self.controller = None
|
||||
# Konfiguriere das Hauptframe, um sich zu dehnen
|
||||
self.grid_rowconfigure(0, weight=1)
|
||||
self.grid_columnconfigure(0, weight=1) # Linke Spalte soll sich dehnen
|
||||
self.grid_columnconfigure(1, weight=0) # Mittlere Spalte (Button) soll sich nicht dehnen
|
||||
self.grid_columnconfigure(2, weight=1) # Rechte Spalte soll sich dehnen
|
||||
|
||||
# Linkes Frame
|
||||
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
|
||||
|
||||
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")
|
||||
|
||||
self.input_textbox = ctk.CTkTextbox(self.frame1, height=200)
|
||||
self.input_textbox.grid(row=1, 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
|
||||
self.check_button = ctk.CTkButton(self, text="Check", width=60, height=300, command=self.check_button_event)
|
||||
self.check_button.grid(row=0, column=1, padx=10, pady=10, sticky="nsew")
|
||||
|
||||
# Rechte scrollbare Ansicht
|
||||
self.scrollview = ctk.CTkScrollableFrame(self)
|
||||
self.scrollview.grid(row=0, column=2, padx=10, pady=10, sticky="nsew")
|
||||
|
||||
# Überschrift hinzufügen
|
||||
self.header = ctk.CTkLabel(self.scrollview, text="Leaderboard", font=("Arial", 24, "bold"))
|
||||
self.header.pack(pady=10, padx=10, anchor="w")
|
||||
|
||||
def set_controller(self, controller):
|
||||
self.controller = controller
|
||||
|
||||
def check_button_event(self):
|
||||
if self.controller:
|
||||
self.controller.press_check_button()
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue