Skip to content

Commit

Permalink
Fix bug can't retrieve file from child component
Browse files Browse the repository at this point in the history
  • Loading branch information
phantichchai committed Aug 30, 2023
1 parent 2709206 commit 0606fff
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions gui/main_window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import tkinter as tk
from tkinter import filedialog
from threading import Thread
from process.processor import run
from gui.file_selector import FileSelector
Expand All @@ -23,14 +22,8 @@ def __init__(self, root):
self.process_button = tk.Button(self.root, text="Process Achievements", command=self.process_achievements)
self.process_button.place(relx=0.5, rely=0.5, anchor="center")

def browse_video(self):
video_path = filedialog.askopenfilename(filetypes=[("Video Files", "*.mp4")])
self.video_path = video_path
if self.video_path:
self.label.config(text=f"Selected Video: {self.video_path}")

def process_achievements(self):
if hasattr(self, "video_path") and self.video_path:
if hasattr(self.file_selector, "selected_file") and self.file_selector.get_selected_file():
self.process_button.config(state=tk.DISABLED)
self.process_button.update()
self.process_thread = Thread(target=self.process_achievements_thread)
Expand All @@ -39,9 +32,12 @@ def process_achievements(self):
self.show_error("Please select a video file.")

def process_achievements_thread(self):
run(self.video_path)
self.show_message("Achievements processing completed.")
self.process_button.config(state=tk.NORMAL)
# Get the selected file from the FileSelector instance
video_path = self.file_selector.get_selected_file()
if video_path:
run(video_path)
self.show_message("Achievements processing completed.")
self.process_button.config(state=tk.NORMAL)

def show_error(self, message):
tk.messagebox.showerror("Error", message)
Expand Down

0 comments on commit 0606fff

Please sign in to comment.