Skip to content

Commit

Permalink
Fixed some bugs and updated ux. Also now the window doesn't freeze wh…
Browse files Browse the repository at this point in the history
…en downloading.
  • Loading branch information
StDensity committed May 14, 2024
1 parent d39c005 commit f3be301
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions YouTubeToMP3/YouTubeToMP3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pytube import YouTube
import customtkinter as ctk
from tkinter import filedialog
import threading

def resource_path(relative_path):
try:
Expand All @@ -16,7 +17,11 @@ def resource_path(relative_path):

def select_output_folder():
global folder_path
folder_path = filedialog.askdirectory() # Open folder selection dialog
folder_path = filedialog.askdirectory()
if folder_path:
download_info_label.configure(text=f"Selected folder: {folder_path}")
else:
download_info_label.configure(text="No folder selected.")

def download_mp3():
video_url = url.get()
Expand Down Expand Up @@ -60,7 +65,8 @@ def download_mp3():
select_output_folder_button = ctk.CTkButton(master=frame, text="Select Output Folder", command=select_output_folder)
select_output_folder_button.place(relx=0.61, rely=0.4, anchor=tkinter.CENTER)

download_button = ctk.CTkButton(master=frame, text="Download MP3", command=download_mp3)
# Deamon=True -> Daemon threads automatically terminate when the main thread (Tkinter's main loop) exits.
download_button = ctk.CTkButton(master=frame, text="Download MP3", command=lambda: threading.Thread(target=download_mp3, daemon=True).start())
download_button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)

download_info_label = ctk.CTkLabel(master=frame, text="")
Expand Down

0 comments on commit f3be301

Please sign in to comment.