Skip to content

Commit

Permalink
Prepares for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyThompson10 committed Dec 7, 2023
1 parent 6878950 commit 0366525
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
29 changes: 26 additions & 3 deletions SpectrumAnalyzerGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, widget, text):
self.tooltip_window = None
widget.bind("<Enter>", self.enter)
widget.bind("<Leave>", self.leave)

# Create the tooltip window
def enter(self, event=None):
x = y = 0
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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("<Button-1>", 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
Expand Down Expand Up @@ -458,4 +481,4 @@ def edit_color(self, color_var_name):
if __name__ == "__main__":
app = SpectrumAnalyzerGUI()
app.mainloop()
app.destroy()
# app.safe_close()
37 changes: 37 additions & 0 deletions SpectrumAnalyzerGUI.spec
Original file line number Diff line number Diff line change
@@ -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,
)

0 comments on commit 0366525

Please sign in to comment.