Skip to content

Commit

Permalink
add do not close terminal option to gui
Browse files Browse the repository at this point in the history
  • Loading branch information
NevermindNilas committed Jun 21, 2024
1 parent ef4adeb commit 305aed0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 13 additions & 3 deletions src/uiLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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])
Expand All @@ -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:
Expand All @@ -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}")

Expand Down Expand Up @@ -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}")
Expand All @@ -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()
Expand Down

0 comments on commit 305aed0

Please sign in to comment.