diff --git a/SpectrumAnalyzerGUI.py b/SpectrumAnalyzerGUI.py index 4c807cd..a0146f2 100644 --- a/SpectrumAnalyzerGUI.py +++ b/SpectrumAnalyzerGUI.py @@ -17,7 +17,7 @@ def __init__(self, widget, text): self.tooltip_window = None widget.bind("", self.enter) widget.bind("", self.leave) - + # Create the tooltip window def enter(self, event=None): x = y = 0 @@ -66,6 +66,16 @@ def __init__(self): self.create_main_page() # Create the main page in the screen frame + # Protocol handler for window close event + self.protocol("WM_DELETE_WINDOW", self.safe_close) + + # Method to safely close the application + def safe_close(self): + # + + if self.winfo_exists(): # Check if the window exists + self.destroy() # Destroy the window + def create_video_display(self): # This function should only be called once to set up the video display initially self.image_label = ttk.Label(self.video_frame) @@ -133,6 +143,12 @@ def create_main_page(self): def display_video_frame(self): video_folder_path = env_vars.Env_Vars.VIDEO_FOLDER + + # Check if the video folder exists, and if not, create it + if not os.path.exists(video_folder_path): + os.makedirs(video_folder_path) + + # Get the first video file in the folder video_files = [f for f in os.listdir(video_folder_path) if f.endswith('.mp4')] if video_files: @@ -162,8 +178,15 @@ def display_video_frame(self): else: print("Failed to open video file") else: - print("No video files found") + print("Failed to open video file") + self.image_label.config(text="No videos found in the video folder.\nClick here to open the video folder.", + cursor="hand2") + self.image_label.bind("", lambda e: self.open_video_folder(video_folder_path)) + def open_video_folder(self, path): + import webbrowser + webbrowser.open(path) + # Get the number of videos in the video folder def get_video_count(self): video_folder_path = env_vars.Env_Vars.VIDEO_FOLDER @@ -458,4 +481,4 @@ def edit_color(self, color_var_name): if __name__ == "__main__": app = SpectrumAnalyzerGUI() app.mainloop() - app.destroy() \ No newline at end of file + # app.safe_close() \ No newline at end of file diff --git a/SpectrumAnalyzerGUI.spec b/SpectrumAnalyzerGUI.spec new file mode 100644 index 0000000..fd20c89 --- /dev/null +++ b/SpectrumAnalyzerGUI.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['SpectrumAnalyzerGUI.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='SpectrumAnalyzerGUI', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +)