Skip to content

Commit

Permalink
Merge pull request #2 from Kidsnd274/pyinstaller
Browse files Browse the repository at this point in the history
Pyinstaller
  • Loading branch information
Kidsnd274 authored Apr 16, 2024
2 parents 40cb4fe + 64bad8b commit 017da2e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
3 changes: 3 additions & 0 deletions build_exe.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
call .\venv\Scripts\activate.bat
pyinstaller --noconfirm --onedir --windowed --add-data "./MediaAutomationScripts;MediaAutomationScripts/" --add-data "./venv/Lib/site-packages/customtkinter;customtkinter/" --name VerifyVideoGUI main.py
copy .\etc\readme.txt .\dist\VerifyVideoGUI
3 changes: 3 additions & 0 deletions etc/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You will need python.exe, ffmpeg.exe, and ffprobe.exe in PATH to use all the features of this program.

Extract the contents of the zip file, including the _internal folder.
8 changes: 7 additions & 1 deletion ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from util.verify_options_object import VerifyOptionsObject
from ui.middle_frame import MiddleFrame
from ui.bottom_frame import BottomFrame
from ui.window_dialog import WindowDialog

class MainWindow():
def __init__(self, root, verifier_function):
Expand Down Expand Up @@ -41,11 +42,16 @@ def toggle_filter_checkbox(self):
self.filter_suffix_entry.configure(state="disabled")
print("checkbox disabled")

def on_verify_button_clicked(self):
def on_verify_button_clicked(self):
folder_path = self.folder_path_variable.get()
ignore_ffmpeg = self.skip_ffmpeg_variable.get() == "on"
filter_staxrip_suffix = self.filter_suffix_variable.get() == "on"

if not folder_path:
error_dialog = WindowDialog(self.root, "Your folder path cannot be empty!")
error_dialog.wait_window()
return

self.disable_ui()

options = VerifyOptionsObject(folder_path, ignore_ffmpeg, filter_staxrip_suffix)
Expand Down
25 changes: 25 additions & 0 deletions ui/window_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import customtkinter as ctk

class WindowDialog(ctk.CTkToplevel):
def __init__(self, parent, message, *args, **kwargs):
super().__init__(*args, **kwargs)
self.parent = parent
self.title("Warning")
self.geometry("250x110")
self.resizable(False, False)
# self.attributes("-toolwindow", True)

self.label = ctk.CTkLabel(self, text=message)
self.label.pack(padx=20, pady=20)

self.okay_button = ctk.CTkButton(self, text="Ok", command=self.on_button_event)
self.okay_button.pack()

# Modal configuration
self.transient(parent) # This makes the dialog a transient window of parent, which means it will minimize and close with the parent window. Also gets rid of the minimize button
self.grab_set() # Prevents input to the main window
self.protocol("WM_DELETE_WINDOW", self.on_button_event) # Handle close button click

def on_button_event(self):
self.destroy()
self.parent.focus_set()
19 changes: 16 additions & 3 deletions util/app_logic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from util.verify_options_object import VerifyOptionsObject
import threading
import os
import sys
import subprocess

def call_verifier(optionsObject, callbackFunction):
thread = threading.Thread(target=start_subprocess, args=(optionsObject, callbackFunction, ), daemon=True)
Expand All @@ -10,9 +12,20 @@ def start_subprocess(optionsObject, callbackFunction):
skip_ffmpeg = optionsObject.skip_ffmpeg
filter_suffix = optionsObject.filter_staxrip_suffix

import subprocess
# Check if we are running as a bundled application
if getattr(sys, 'frozen', False):
# If the application is run as a bundle, the pyInstaller bootloader
# extends the sys module by a flag frozen=True and sets the app
# path into variable _MEIPASS'.
application_path = sys._MEIPASS
else:
# Otherwise, we are running in a normal Python environment
application_path = '.'

# Adjust the script path according to the environment
script_path = os.path.join(application_path, 'MediaAutomationScripts', 'VerifyVideo.py')

python_interpreter = 'python'
script_path = './MediaAutomationScripts/VerifyVideo.py'
creation_flag = subprocess.CREATE_NEW_CONSOLE
args = [
python_interpreter,
Expand Down

0 comments on commit 017da2e

Please sign in to comment.