Skip to content

Commit b2da684

Browse files
chopan050henrikmidtiby
authored andcommitted
Fix type of window_size in opengl_renderer_window.py
1 parent 73f4382 commit b2da684

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

manim/renderer/opengl_renderer_window.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,23 @@ class Window(PygletWindow):
2525
def __init__(
2626
self,
2727
renderer: OpenGLRenderer,
28-
window_size: str = config.window_size,
28+
window_size: str | tuple[int, ...] = config.window_size,
2929
**kwargs: Any,
3030
) -> None:
3131
monitors = get_monitors()
3232
mon_index = config.window_monitor
3333
monitor = monitors[min(mon_index, len(monitors) - 1)]
3434

35-
if window_size == "default":
35+
invalid_window_size_error_message = (
36+
"window_size must be specified either as 'default', a string of the form "
37+
"'width,height', or a tuple of 2 ints of the form (width, height)."
38+
)
39+
40+
if isinstance(window_size, tuple):
41+
if len(window_size) != 2:
42+
raise ValueError(invalid_window_size_error_message)
43+
size = window_size
44+
elif window_size == "default":
3645
# make window_width half the width of the monitor
3746
# but make it full screen if --fullscreen
3847
window_width = monitor.width
@@ -48,9 +57,7 @@ def __init__(
4857
(window_width, window_height) = tuple(map(int, window_size.split(",")))
4958
size = (window_width, window_height)
5059
else:
51-
raise ValueError(
52-
"Window_size must be specified as 'width,height' or 'default'.",
53-
)
60+
raise ValueError(invalid_window_size_error_message)
5461

5562
super().__init__(size=size)
5663

0 commit comments

Comments
 (0)