@@ -25,14 +25,23 @@ class Window(PygletWindow):
25
25
def __init__ (
26
26
self ,
27
27
renderer : OpenGLRenderer ,
28
- window_size : str = config .window_size ,
28
+ window_size : str | tuple [ int , ...] = config .window_size ,
29
29
** kwargs : Any ,
30
30
) -> None :
31
31
monitors = get_monitors ()
32
32
mon_index = config .window_monitor
33
33
monitor = monitors [min (mon_index , len (monitors ) - 1 )]
34
34
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" :
36
45
# make window_width half the width of the monitor
37
46
# but make it full screen if --fullscreen
38
47
window_width = monitor .width
@@ -48,9 +57,7 @@ def __init__(
48
57
(window_width , window_height ) = tuple (map (int , window_size .split ("," )))
49
58
size = (window_width , window_height )
50
59
else :
51
- raise ValueError (
52
- "Window_size must be specified as 'width,height' or 'default'." ,
53
- )
60
+ raise ValueError (invalid_window_size_error_message )
54
61
55
62
super ().__init__ (size = size )
56
63
0 commit comments