Repository navigation
Expand file tree
/
Copy pathtempCodeRunnerFile.py
More file actions
98 lines (81 loc) · 3.24 KB
/
Copy pathtempCodeRunnerFile.py
File metadata and controls
98 lines (81 loc) · 3.24 KB
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
import FreeSimpleGUI as sg
from utils.zip_creator import make_archive
from utils.zip_extractor import extract_archive
def main():
sg.theme("Black")
sg.set_options(font=("Helvetica", 11))
comp_label1 = sg.Text("Select files to compress: ")
comp_input1 = sg.Input(key="comp_files")
comp_choose1 = sg.FilesBrowse("Choose")
comp_label2 = sg.Text("Select destination folder: ")
comp_input2 = sg.Input(key="comp_folder")
comp_choose2 = sg.FolderBrowse("Choose")
compress_button = sg.Button("Compress", size=(12, 1))
comp_output = sg.Text(key="comp_output", text_color="green")
compress_layout = [
[comp_label1, comp_input1, comp_choose1],
[comp_label2, comp_input2, comp_choose2],
[compress_button, comp_output],
]
ext_label1 = sg.Text("Select archive:")
ext_input1 = sg.Input(key="ext_archive")
ext_choose1 = sg.FileBrowse("Choose")
ext_label2 = sg.Text("Select dest dir:")
ext_input2 = sg.Input(key="ext_folder")
ext_choose2 = sg.FolderBrowse("Choose")
extract_button = sg.Button("Extract", size=(12, 1))
ext_output = sg.Text(key="ext_output", text_color="green")
extract_layout = [
[ext_label1, ext_input1, ext_choose1],
[ext_label2, ext_input2, ext_choose2],
[extract_button, ext_output],
]
main_layout = [
[
sg.TabGroup(
[
[
sg.Tab("Compress", compress_layout, element_justification="c"),
sg.Tab("Extract", extract_layout, element_justification="c"),
]
]
)
]
]
window = sg.Window("Archive Manager", main_layout, margins=(20, 20))
while True:
event, values = window.read()
match event:
case sg.WIN_CLOSED:
break
case "Compress":
if values["comp_files"] != "" and values["comp_folder"] != "":
filepaths = values["comp_files"].split(";")
folder = values["comp_folder"]
make_archive(filepaths, folder)
window["comp_output"].update(
value="Compression completed!", text_color="green"
)
else:
sg.popup_error(
"Please select files and a destination folder!",
title="Missing Information",
)
window["comp_output"].update(value="")
case "Extract":
if values["ext_archive"] != "" and values["ext_folder"] != "":
archive_path = values["ext_archive"]
dest_dir = values["ext_folder"]
extract_archive(archive_path, dest_dir)
window["ext_output"].update(
value="Extraction completed!", text_color="green"
)
else:
sg.popup_error(
"Please select an archive and a destination folder!",
title="Missing Information",
)
window["ext_output"].update(value="")
window.close()
if __name__ == "__main__":
main()