A community-maintained Python framework for creating mathematical animations.
Add cross-platform file opening method.
Aathish Sivasubrahmanian7f4a88dd95f6
diff --git a/manim/utils/file_ops.py b/manim/utils/file_ops.pyindex 181cfb426..76033d49f 100644--- a/manim/utils/file_ops.py+++ b/manim/utils/file_ops.py@@ -1,4 +1,6 @@import os+import subprocess as sp+import platformimport numpy as np@@ -56,4 +58,19 @@ def get_sorted_integer_files(directory,elif remove_non_integer_files:os.remove(full_path)indexed_files.sort(key=lambda p: p[0])- return list(map(lambda p: os.path.join(directory, p[1]), indexed_files))\ No newline at end of file+ return list(map(lambda p: os.path.join(directory, p[1]), indexed_files))++def open_file(file_path):+ current_os = platform.system()+ if current_os == "Windows":+ os.startfile(file_path)+ else:+ commands = []+ if current_os == "Linux":+ commands.append("xdg-open")+ elif current_os.startswith("CYGWIN"):+ commands.append("cygstart")+ else: # Assume macOS+ commands.append("open")+ commands.append(file_path)+ sp.Popen(commands)\ No newline at end of file