-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgui.py
More file actions
68 lines (51 loc) · 2.79 KB
/
gui.py
File metadata and controls
68 lines (51 loc) · 2.79 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
import customtkinter
from downloader import *
import shutil
import threading
#COMMON USE VARIABLES
DOWNLOAD_DEST_PATH = "maps/"
ZIPFILE_PATH = "pool/"
PAD_Y = 8
# Setting up window
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("green")
class Gui:
def __init__(self):
self.root = customtkinter.CTk()
self.root.geometry("1024x768")
self.root.title("beatmap-downloader")
# Frame object, contains all the elements of the app
self.frame = customtkinter.CTkFrame(master=self.root)
self.frame.pack(pady=20, padx=60, fill="both", expand=True)
# Beatmap ID label and entry
self.enter_bid_label = customtkinter.CTkLabel(master=self.frame, text="Enter beatmap IDs:")
self.enter_bid_label.pack(pady=PAD_Y, padx=10)
self.bid_entry = customtkinter.CTkTextbox(master=self.frame, width=454, height=150)
self.bid_entry.pack(pady=PAD_Y, padx=10)
# Download path label and entry
self.download_path_label = customtkinter.CTkLabel(master=self.frame, text="Download path (File that gets zipped): ")
self.download_path_label.pack(pady=PAD_Y, padx=10)
# Inserts placeholder text in the entry
self.download_path_entry = customtkinter.CTkTextbox(master=self.frame, width=454, height=20)
self.download_path_entry.insert("0.0", DOWNLOAD_DEST_PATH)
self.download_path_entry.pack(pady=PAD_Y, padx=10)
# Zipfile path label and entry
self.zip_path_label = customtkinter.CTkLabel(master=self.frame, text="Zip destination: ")
self.zip_path_label.pack(pady=PAD_Y, padx=10)
self.zip_path_entry = customtkinter.CTkTextbox(master=self.frame, width=454, height=20)
self.zip_path_entry.insert("0.0", ZIPFILE_PATH)
self.zip_path_entry.pack(pady=PAD_Y, padx=10)
# Initialise downloader object
self.downloader = Downloader(self.frame)
# Download button, calls the initialize download function
self.download_button = customtkinter.CTkButton(master=self.frame, text="DONLOAD", command=lambda:self.downloader.initialize_download(self))
self.download_button.pack(pady=PAD_Y, padx=10)
# Zip button, zips the download file and stores it in specified location
self.zip_button = customtkinter.CTkButton(master=self.frame, text="Create .zip", command=self.zip_download_file)
self.zip_button.pack(pady=PAD_Y, padx=10)
self.root.mainloop()
def zip_download_file(self):
"""Called by the zip button. Zips the download destination file at the zipfile path"""
# Initialises zip thread to prevent freezing the window during zipping
zip_thread = threading.Thread(target=lambda:shutil.make_archive(ZIPFILE_PATH, 'zip', DOWNLOAD_DEST_PATH))
zip_thread.start()