diff --git a/gui.py b/gui.py index 1124f0f1..70bfd91c 100644 --- a/gui.py +++ b/gui.py @@ -208,6 +208,10 @@ def createWidgets(self): "Rife Ensemble", "Enable or disable RIFE ensemble, this can improve the quality of the interpolation at the cost of less performance.", ), + ( + "Do not Close Terminal on Finish", + "Do not close the terminal window after the script has finished running, used for debugging purposes.", + ) ] for text, help_text in checkboxes: diff --git a/src/uiLogic.py b/src/uiLogic.py index 46ab5c64..7791d644 100644 --- a/src/uiLogic.py +++ b/src/uiLogic.py @@ -3,7 +3,7 @@ import threading import logging -from PyQt6.QtWidgets import QCheckBox, QGraphicsOpacityEffect, QLineEdit +from PyQt6.QtWidgets import QCheckBox, QGraphicsOpacityEffect from PyQt6.QtCore import QPropertyAnimation, QEasingCurve def Style() -> str: @@ -102,6 +102,8 @@ def runCommand(self, mainPath, settingsFile) -> None: loadSettingsFile = json.load(open(settingsFile)) + DontcloseTerminal = loadSettingsFile.get("close_terminal") + for option in loadSettingsFile: loweredOption = option.lower() loweredOptionValue = str(loadSettingsFile[option]) @@ -119,6 +121,9 @@ def runCommand(self, mainPath, settingsFile) -> None: if loweredOptionValue == "false": continue + if loweredOption == "close_terminal": + continue + if loweredOption in ["input", "output"]: command.append(f"--{loweredOption} \"{loweredOptionValue}\"") else: @@ -132,9 +137,12 @@ def runCommand(self, mainPath, settingsFile) -> None: def runCommandInTerminal(command): # Check if Windows Terminal (wt) is available wt_available = os.system('where wt >nul 2>&1') - terminal_command = f'start wt cmd /c {command}' if wt_available == 0 else f'start cmd /c {command}' + if DontcloseTerminal: + terminalCommand = f'start wt cmd /k {command}' if wt_available == 0 else f'start cmd /k {command}' + else: + terminalCommand = f'start wt cmd /c {command}' if wt_available == 0 else f'start cmd /c {command}' try: - os.system(terminal_command) + os.system(terminalCommand) except Exception as e: print(f"An error occurred while running the command: {e}") @@ -188,6 +196,7 @@ def loadSettings(self, settingsFile): self.benchmarkmodeCheckbox.setChecked(settings.get("benchmark", False)) self.scenechangedetectionCheckbox.setChecked(settings.get("scenechange", False)) self.rifeensembleCheckbox.setChecked(settings.get("ensemble", False)) + self.donotcloseterminalonfinishCheckbox.setChecked(settings.get("close_terminal", False)) except Exception as e: self.outputWindow.append(f"An error occurred while loading settings, {e}") @@ -212,6 +221,7 @@ def saveSettings(self, settingsFile): "benchmark": self.benchmarkmodeCheckbox.isChecked(), "scenechange": self.scenechangedetectionCheckbox.isChecked(), "ensemble": self.rifeensembleCheckbox.isChecked(), + "close_terminal": self.donotcloseterminalonfinishCheckbox.isChecked(), } for i in range(self.checkboxLayout.count()): checkbox = self.checkboxLayout.itemAt(i).widget()