-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend.py
102 lines (69 loc) · 3.41 KB
/
frontend.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
# PYTHON VERSION: 3.11.9
import os.path
import tkinter as tk
from tkinter.messagebox import askyesno
import json
import backend as bkd
import utils.utiles as util
class App:
logger = ""
path_dict = os.path.join("texts", "strings.json")
with open(path_dict, "r", encoding="utf-8") as file:
strings = json.load(file)
text_logger = strings["text"]
def __init__(self):
self.first_directory = None
self.second_directory = None
self.main_window = tk.Tk()
self.main_window.geometry("1024x400")
self.main_window.title(self.text_logger["title"])
self.main_window.configure(bg="#1a242b")
self.main_window.resizable(False, False)
self.first_main_window = util.get_button(self.main_window, self.text_logger["first_path"], "green", self.first_path_button)
self.first_main_window.place(x=860, y=35)
self.second_main_window = util.get_button(self.main_window, self.text_logger["second_path"], "green", self.second_path_button)
self.second_main_window.place(x=860, y=80)
self.execute_main_window = util.get_button(self.main_window, self.text_logger["run"], "red", self.execute_button)
self.execute_main_window.config(state=tk.DISABLED)
self.execute_main_window.place(x=860, y=125)
self.label_border = tk.Frame(self.main_window, bg="#f0f0f0", relief="sunken", bd=2)
self.label_text = tk.Label(self.label_border, font=("Consolas", 10), justify="left", anchor="nw", width=115, height=35, bg="#131313", fg="#f0f0f0")
self.label_text.pack(fill="both", expand=True, padx=1, pady=1)
self.label_border.pack(anchor="nw", padx=15, pady=15)
self.output()
def first_path_button(self):
self.first_directory = bkd.select_file()
self.switch_state()
self.logger += self.text_logger["selected_first_message"].format(first_directory=self.first_directory)+"\n"
def second_path_button(self):
self.second_directory = bkd.select_file()
self.switch_state()
self.logger += self.text_logger["selected_second_message"].format(second_directory=self.second_directory)+"\n"
def execute_button(self):
answer_execute = askyesno(self.text_logger["run"], self.text_logger["checking_message"])
if answer_execute:
self.logger += self.text_logger["start_message"]+"\n"
html_diff = bkd.read_files(self.first_directory, self.second_directory)
self.logger += self.text_logger["comparison_message"]+"\n"
output_directory = bkd.create_output_folder()
bkd.save_file(output_directory, html_diff)
self.logger += self.text_logger["html_message"]+"\n"
else:
pass
def switch_state(self):
if self.first_directory == None or self.second_directory == None:
self.execute_main_window.config(state=tk.DISABLED)
else:
self.execute_main_window.config(state=tk.NORMAL)
def output(self):
self.label_text.config(text=self.logger)
self.main_window.after(1000, self.output)
def exit_button(self):
answer_exit = askyesno(self.text_logger["exit"], self.text_logger["checking_message"])
if answer_exit:
self.main_window.destroy()
else:
pass
def start(self):
self.main_window.protocol("WM_DELETE_WINDOW", self.exit_button)
self.main_window.mainloop()