7
7
8
8
9
9
# Event handlers that can be applied to instances of Arcade.Window and Pyglet.window.Window
10
- def on_keyboard_press (self , symbol , modifiers ):
11
- close_all_windows ()
10
+ def _on_keyboard_press (self , symbol , modifiers ):
11
+ _close_all_windows ()
12
12
13
13
14
- def on_mouse_press (self , x , y , button , modifiers ):
15
- close_all_windows ()
14
+ def _on_mouse_press (self , x , y , button , modifiers ):
15
+ _close_all_windows ()
16
16
17
17
18
- def on_mouse_motion (self , x , y , dx , dy ):
18
+ def _on_mouse_motion (self , x , y , dx , dy ):
19
19
# A Window almost always gets an initial on_mouse_motion event when window opens.
20
20
# Ignore the first motion event. I think a motion event is triggered when the
21
21
# window is opening and the mouse cursor is already inside the window's boundary.
22
22
if self .first_mouse_motion_event :
23
23
self .first_mouse_motion_event = False
24
24
return
25
- close_all_windows ()
25
+ _close_all_windows ()
26
26
27
27
28
- def on_close (self ):
29
- close_all_windows ()
28
+ def _on_close (self ):
29
+ _close_all_windows ()
30
30
31
31
32
- def close_all_windows ():
32
+ def _close_all_windows ():
33
33
for win in all_windows :
34
34
win .close ()
35
35
36
36
37
- def get_preferred_screen (screens ):
37
+ def _get_preferred_screen (screens ):
38
38
"""Choose the screen with the most pixels to show the screensaver on"""
39
39
ordered_screens = [(s .width * s .height , idx , s ) for idx , s in enumerate (screens )]
40
40
ordered_screens .sort () # sort by # of pixels, then screen index, then object
@@ -43,19 +43,19 @@ def get_preferred_screen(screens):
43
43
44
44
def _make_windows (screensaver_window_class , is_fullscreen , win_kwargs ):
45
45
# Monkeypatch Arcade and Pyglet window classes (for easier code-reuse)
46
- screensaver_window_class .on_key_press = on_keyboard_press
47
- screensaver_window_class .on_mouse_press = on_mouse_press
48
- screensaver_window_class .on_mouse_motion = on_mouse_motion
49
- screensaver_window_class .on_close = on_close
46
+ screensaver_window_class .on_key_press = _on_keyboard_press
47
+ screensaver_window_class .on_mouse_press = _on_mouse_press
48
+ screensaver_window_class .on_mouse_motion = _on_mouse_motion
49
+ screensaver_window_class .on_close = _on_close
50
50
51
- pyglet .window .Window .on_key_press = on_keyboard_press
52
- pyglet .window .Window .on_mouse_press = on_mouse_press
53
- pyglet .window .Window .on_mouse_motion = on_mouse_motion
54
- pyglet .window .Window .on_close = on_close
51
+ pyglet .window .Window .on_key_press = _on_keyboard_press
52
+ pyglet .window .Window .on_mouse_press = _on_mouse_press
53
+ pyglet .window .Window .on_mouse_motion = _on_mouse_motion
54
+ pyglet .window .Window .on_close = _on_close
55
55
56
56
display = pyglet .canvas .get_display ()
57
57
screens = display .get_screens ()
58
- preferred_screen = get_preferred_screen (screens )
58
+ preferred_screen = _get_preferred_screen (screens )
59
59
main_win = None
60
60
for screen in screens :
61
61
if screen == preferred_screen :
0 commit comments