2024-12-17 11:25:44 +00:00
|
|
|
import os
|
2024-12-30 23:35:40 +01:00
|
|
|
from argparse import ArgumentParser
|
2024-12-31 12:06:11 +01:00
|
|
|
|
2024-12-30 23:35:40 +01:00
|
|
|
# Mainly from ChatGPT
|
|
|
|
def check_pyside_installed():
|
|
|
|
try:
|
|
|
|
import PySide6 # Replace with PySide2 if using that version
|
|
|
|
return True
|
|
|
|
except ImportError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def start_gui():
|
|
|
|
import gui
|
|
|
|
gui.main(exif_file)
|
|
|
|
|
|
|
|
def start_tui():
|
|
|
|
import tui
|
2024-12-31 12:06:11 +01:00
|
|
|
tui.main(exif_file, tui_settings_file)
|
2024-12-30 23:35:40 +01:00
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = ArgumentParser(description="Start the Optima35 application.")
|
|
|
|
parser.add_argument("--tui", action="store_true", help="Start in terminal UI mode.")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if args.tui:
|
|
|
|
print("Starting TUI...")
|
|
|
|
start_tui()
|
2024-12-30 20:19:49 +00:00
|
|
|
return
|
2024-12-17 11:25:44 +00:00
|
|
|
|
2024-12-30 23:35:40 +01:00
|
|
|
# Check OS and start GUI if on Windows
|
|
|
|
if os.name == "nt":
|
|
|
|
print("Detected Windows. Starting GUI...")
|
|
|
|
start_gui()
|
|
|
|
else:
|
|
|
|
# Non-Windows: Check if PySide is installed
|
|
|
|
if check_pyside_installed():
|
|
|
|
print("PySide detected. Starting GUI...")
|
|
|
|
start_gui()
|
|
|
|
else:
|
|
|
|
print("PySide is not installed. Falling back to TUI...")
|
|
|
|
start_tui()
|
2024-12-17 11:25:44 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-12-31 12:06:11 +01:00
|
|
|
if os.path.isfile("config/exif.yaml"):
|
|
|
|
exif_file = "config/exif.yaml"
|
|
|
|
elif os.path.isfile("config/exif_example.yaml"):
|
|
|
|
exif_file = "config/exif_example.yaml"
|
|
|
|
print("Fall back to exif example file...")
|
|
|
|
else:
|
|
|
|
print("Exif file missing, please ensure an exif file exist in config folder (exif.yaml, or exif_example_yaml)\nExiting...")
|
|
|
|
exit()
|
|
|
|
tui_settings_file = "config/tui_settings.yaml"
|
2024-12-30 23:35:40 +01:00
|
|
|
main()
|