Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Use os.openfile() on Windows and gitignore media folder (#384)

F.W11781a5baaae
diff --git a/.gitignore b/.gitignore
index ae612633c..54885c871 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,8 +11,10 @@ ben_playground.py
ben_cairo_test.py
.floo
.flooignore
+.vscode
*.xml
*.iml
+media
manim.sublime-project
manim.sublime-workspace
diff --git a/manimlib/extract_scene.py b/manimlib/extract_scene.py
index 36894e5b5..80fc78a1c 100644
--- a/manimlib/extract_scene.py
+++ b/manimlib/extract_scene.py
@@ -25,23 +25,33 @@ def handle_scene(scene, **config):
config["show_file_in_finder"]
])
if open_file:
- commands = ["open"]
- if (platform.system() == "Linux"):
- commands = ["xdg-open"]
- elif (platform.system() == "Windows"):
- commands = ["start"]
-
- if config["show_file_in_finder"]:
- commands.append("-R")
+ current_os = platform.system()
+ file_path = None
if config["show_last_frame"]:
- commands.append(scene.get_image_file_path())
+ file_path = scene.get_image_file_path()
+ else:
+ file_path = scene.get_movie_file_path()
+
+ if current_os == "Windows":
+ os.startfile(file_path)
else:
- commands.append(scene.get_movie_file_path())
- # commands.append("-g")
- FNULL = open(os.devnull, 'w')
- sp.call(commands, stdout=FNULL, stderr=sp.STDOUT)
- FNULL.close()
+ commands = []
+
+ if (current_os == "Linux"):
+ commands.append("xdg-open")
+ else: # Assume macOS
+ commands.append("open")
+
+ if config["show_file_in_finder"]:
+ commands.append("-R")
+
+ commands.append(file_path)
+
+ # commands.append("-g")
+ FNULL = open(os.devnull, 'w')
+ sp.call(commands, stdout=FNULL, stderr=sp.STDOUT)
+ FNULL.close()
if config["quiet"]:
sys.stdout.close()