Skip to content

Commit

Permalink
Merge branch 'threading-feature'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kidsnd274 committed Apr 16, 2024
2 parents f1a731f + 048049b commit 40cb4fe
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
31 changes: 27 additions & 4 deletions ui/bottom_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,38 @@ def __init__(self, master, options_dict):
offvalue="off", variable=options_dict['filter_suffix_variable'])
self.filter_suffix_checkbox.grid(row=2, column=0, padx=10, pady=(10,10), sticky='w')
# self.filter_suffix_entry = ctk.CTkEntry(self, textvariable=self.suffix_var, placeholder_text="_new", state="disabled")

def disable_frame(self):
for widget in self.winfo_children():
widget.configure(state="disabled")

def enable_frame(self):
for widget in self.winfo_children():
widget.configure(state="normal")

class BottomFrame(ctk.CTkFrame):
def __init__(self, master, options_dict, verify_button_event):
super().__init__(master)
self.button_original_color = ""

self.grid_columnconfigure(1, weight=1)

options_frame = OptionsCheckboxFrame(self, options_dict)
options_frame.grid(row=0, column=0, sticky="nsew")
self.options_frame = OptionsCheckboxFrame(self, options_dict)
self.options_frame.grid(row=0, column=0, sticky="nsew")

self.verify_button = ctk.CTkButton(self, text="Verify Video", command=verify_button_event)
self.verify_button.grid(row=0, column=1, padx=20, pady=20, sticky="nsew")
self.button_original_color = self.verify_button.cget("fg_color")

def disable_frame(self):
self.verify_button.configure(fg_color='red')
self.verify_button.configure(text="Verifying...")
self.verify_button.configure(state="disabled")
self.options_frame.disable_frame()

verify_button = ctk.CTkButton(self, text="Verify Video", command=verify_button_event)
verify_button.grid(row=0, column=1, padx=20, pady=20, sticky="nsew")
def enable_frame(self):
self.verify_button.configure(fg_color=self.button_original_color)
self.verify_button.configure(text="Verify Video")
self.verify_button.configure(state="normal")
self.options_frame.enable_frame()

25 changes: 20 additions & 5 deletions ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ def __init__(self, root, verifier_function):
title_label = ctk.CTkLabel(root, text="VerifyVideoGUI", justify="center", font=title_font)
title_label.grid(row=0, column=0, padx=20, pady=10, sticky="ew", columnspan=100)

middle_frame = MiddleFrame(root, self.folder_path_variable)
middle_frame.grid(row=1)
self.middle_frame = MiddleFrame(root, self.folder_path_variable)
self.middle_frame.grid(row=1)

self.bottom_frame = BottomFrame(root, options_dict, self.on_verify_button_clicked)
self.bottom_frame.grid(row=2, column=0, padx=50, pady=(0, 10), sticky="ew")

bottom_frame = BottomFrame(root, options_dict, self.on_verify_button_clicked)
bottom_frame.grid(row=2, column=0, padx=50, pady=(0, 10), sticky="ew")

def toggle_filter_checkbox(self):
if self.filter_suffix_checkbox.get() == "on":
Expand All @@ -45,5 +46,19 @@ def on_verify_button_clicked(self):
ignore_ffmpeg = self.skip_ffmpeg_variable.get() == "on"
filter_staxrip_suffix = self.filter_suffix_variable.get() == "on"

self.disable_ui()

options = VerifyOptionsObject(folder_path, ignore_ffmpeg, filter_staxrip_suffix)
self.verifier_function(options)
self.verifier_function(options, self.processing_stopped)

def disable_ui(self):
self.middle_frame.disable_frame()
self.bottom_frame.disable_frame()

def enable_ui(self):
self.middle_frame.enable_frame()
self.bottom_frame.enable_frame()

def processing_stopped(self):
self.enable_ui()
self.root.lift()
10 changes: 9 additions & 1 deletion ui/middle_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@ def __init__(self, master, path_variable):
def browseFile(self):
file_path = filedialog.askdirectory()
if file_path:
self.path_variable.set(file_path) # Update the entry with the selected file path
self.path_variable.set(file_path) # Update the entry with the selected file path

def disable_frame(self):
for widget in self.winfo_children():
widget.configure(state="disabled")

def enable_frame(self):
for widget in self.winfo_children():
widget.configure(state="normal")
8 changes: 7 additions & 1 deletion util/app_logic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from util.verify_options_object import VerifyOptionsObject
import threading

def call_verifier(optionsObject):
def call_verifier(optionsObject, callbackFunction):
thread = threading.Thread(target=start_subprocess, args=(optionsObject, callbackFunction, ), daemon=True)
thread.start()

def start_subprocess(optionsObject, callbackFunction):
file_path = optionsObject.folder_path
skip_ffmpeg = optionsObject.skip_ffmpeg
filter_suffix = optionsObject.filter_staxrip_suffix
Expand All @@ -21,6 +26,7 @@ def call_verifier(optionsObject):
args.append('-s')

subprocess.run(args, creationflags=creation_flag)
callbackFunction()

def check_for_ffmpeg_binaries():
pass

0 comments on commit 40cb4fe

Please sign in to comment.