Simplify no-tkinter file dialog fallback

This commit is contained in:
Melbar
2026-05-07 18:08:14 +02:00
parent 5c4cc5b477
commit 27f2f9ce32
2 changed files with 10 additions and 14 deletions
+9 -13
View File
@@ -726,28 +726,24 @@ def run_no_tk_fallback() -> int:
print("Tkinter ist nicht verfuegbar. Starte Drag-and-Drop-Datei direkt im CLI-Modus.")
return run_cli(sys.argv[1], OUTPUT_BASE_DIR)
print("Tkinter ist nicht verfuegbar. Oeffne Windows-Dateidialoge als Fallback.")
selected = choose_paths_with_powershell()
if selected is None:
print("Tkinter ist nicht verfuegbar. Oeffne Windows-Dateidialog als Fallback.")
input_file = choose_input_with_powershell()
if input_file is None:
print("Keine Quelle ausgewaehlt.")
return 1
input_file, output_dir = selected
return run_cli(input_file, output_dir)
print(f"Quelle: {input_file}")
print(f"Ausgabe: {OUTPUT_BASE_DIR}")
return run_cli(input_file, OUTPUT_BASE_DIR)
def choose_paths_with_powershell() -> tuple[str, str] | None:
def choose_input_with_powershell() -> str | None:
script = r"""
Add-Type -AssemblyName System.Windows.Forms
$open = New-Object System.Windows.Forms.OpenFileDialog
$open.Title = 'Basis-Video auswaehlen'
$open.Filter = 'Video-Dateien (*.mov;*.mxf;*.mp4;*.mkv;*.ts;*.m2ts;*.vob)|*.mov;*.mxf;*.mp4;*.mkv;*.ts;*.m2ts;*.vob|Alle Dateien (*.*)|*.*'
if ($open.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) { exit 2 }
$folder = New-Object System.Windows.Forms.FolderBrowserDialog
$folder.Description = 'Ausgabeordner auswaehlen'
$folder.SelectedPath = 'H:\VOD'
if ($folder.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK) { exit 2 }
Write-Output $open.FileName
Write-Output $folder.SelectedPath
"""
result = subprocess.run(
["powershell", "-NoProfile", "-STA", "-Command", script],
@@ -758,9 +754,9 @@ Write-Output $folder.SelectedPath
if result.returncode != 0:
return None
lines = [line.strip() for line in result.stdout.splitlines() if line.strip()]
if len(lines) < 2:
if not lines:
return None
return lines[0], lines[1]
return lines[0]
def main() -> int: