GUI slightly changed.
This commit is contained in:
+59
-17
@@ -4,12 +4,12 @@ from tkinter import filedialog
|
||||
from pytube import YouTube
|
||||
import pickle
|
||||
|
||||
# Speicherort für MP3- und MP4-Dateien
|
||||
# Output directories for MP3 and MP4 files
|
||||
mp3_output_directory = ""
|
||||
mp4_output_directory = ""
|
||||
|
||||
# Dateinamen für die Speicherung der Verzeichnisse
|
||||
config_file = "directories.pickle"
|
||||
# File name for storing the directories
|
||||
config_file = "config/directories.pickle"
|
||||
|
||||
|
||||
def create_directory(directory):
|
||||
@@ -42,7 +42,7 @@ def load_directories():
|
||||
def select_directory(format_type):
|
||||
global mp3_output_directory, mp4_output_directory
|
||||
|
||||
# Dialogfenster für die Auswahl des Ordners öffnen
|
||||
# Open directory selection dialog
|
||||
directory = filedialog.askdirectory()
|
||||
|
||||
if format_type == "mp3":
|
||||
@@ -51,6 +51,56 @@ def select_directory(format_type):
|
||||
mp4_output_directory = directory
|
||||
|
||||
|
||||
def open_settings():
|
||||
settings_window = tk.Toplevel(window)
|
||||
settings_window.title("Settings")
|
||||
settings_window.geometry("300x200")
|
||||
|
||||
# MP3 output directory selection
|
||||
mp3_label = tk.Label(settings_window, text="MP3 Output Directory:")
|
||||
mp3_label.pack()
|
||||
|
||||
mp3_directory_entry = tk.Entry(settings_window, width=50)
|
||||
mp3_directory_entry.insert(tk.END, mp3_output_directory)
|
||||
mp3_directory_entry.pack()
|
||||
|
||||
def select_mp3_directory():
|
||||
directory = filedialog.askdirectory()
|
||||
mp3_directory_entry.delete(0, tk.END)
|
||||
mp3_directory_entry.insert(tk.END, directory)
|
||||
|
||||
mp3_directory_button = tk.Button(settings_window, text="Select Directory", command=select_mp3_directory)
|
||||
mp3_directory_button.pack()
|
||||
|
||||
# MP4 output directory selection
|
||||
mp4_label = tk.Label(settings_window, text="MP4 Output Directory:")
|
||||
mp4_label.pack()
|
||||
|
||||
mp4_directory_entry = tk.Entry(settings_window, width=50)
|
||||
mp4_directory_entry.insert(tk.END, mp4_output_directory)
|
||||
mp4_directory_entry.pack()
|
||||
|
||||
def select_mp4_directory():
|
||||
directory = filedialog.askdirectory()
|
||||
mp4_directory_entry.delete(0, tk.END)
|
||||
mp4_directory_entry.insert(tk.END, directory)
|
||||
|
||||
mp4_directory_button = tk.Button(settings_window, text="Select Directory", command=select_mp4_directory)
|
||||
mp4_directory_button.pack()
|
||||
|
||||
def save_settings():
|
||||
global mp3_output_directory, mp4_output_directory
|
||||
|
||||
mp3_output_directory = mp3_directory_entry.get()
|
||||
mp4_output_directory = mp4_directory_entry.get()
|
||||
save_directories()
|
||||
settings_window.destroy()
|
||||
|
||||
# Save button
|
||||
save_button = tk.Button(settings_window, text="Save", command=save_settings)
|
||||
save_button.pack()
|
||||
|
||||
|
||||
def download_video():
|
||||
url = url_entry.get()
|
||||
save_as_mp3 = mp3_var.get()
|
||||
@@ -115,29 +165,21 @@ quality_var.set("720p") # Default quality
|
||||
quality_dropdown = tk.OptionMenu(window, quality_var, "144p", "240p", "360p", "480p", "720p")
|
||||
quality_dropdown.pack()
|
||||
|
||||
# MP3 output directory selection button
|
||||
mp3_directory_button = tk.Button(window, text="Select MP3 Output Directory",
|
||||
command=lambda: select_directory("mp3"))
|
||||
mp3_directory_button.pack()
|
||||
|
||||
# MP4 output directory selection button
|
||||
mp4_directory_button = tk.Button(window, text="Select MP4 Output Directory",
|
||||
command=lambda: select_directory("mp4"))
|
||||
mp4_directory_button.pack()
|
||||
|
||||
# Download button
|
||||
download_button = tk.Button(window, text="Download", command=download_video)
|
||||
download_button.pack()
|
||||
|
||||
# Settings button
|
||||
settings_button = tk.Button(window, text="⚙️", width=2, command=open_settings)
|
||||
settings_button.pack(side=tk.RIGHT, padx=10, pady=10)
|
||||
|
||||
# Status label
|
||||
status_label = tk.Label(window, text="")
|
||||
status_label.pack()
|
||||
|
||||
# Load directories
|
||||
# Load directories from config
|
||||
load_directories()
|
||||
|
||||
# Save directories before closing the window
|
||||
window.protocol("WM_DELETE_WINDOW", lambda: [save_directories(), window.destroy()])
|
||||
|
||||
# Start GUI
|
||||
window.mainloop()
|
||||
|
||||
Reference in New Issue
Block a user