File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 4444 :param bool always_on_top: Create a window that is always presented above
4545 others.
4646
47+ Event behavior if one Window is created: When the close button is pressed,
48+ the ``QUIT `` event will be sent to the event queue.
49+
50+ .. code-block :: python
51+
52+ import pygame
53+
54+ window = pygame.Window()
55+
56+ while True :
57+ for event in pygame.event.get():
58+ if event.type == pygame.QUIT :
59+ pygame.quit()
60+ raise SystemExit
61+
62+ Event behavior if multiple Windows are created: When the close button is
63+ pressed, a ``WINDOWCLOSE `` event is sent. You need to explicitly destroy
64+ the window. Note that the event ``QUIT `` will only be sent if all Window
65+ has been destroyed.
66+
67+ .. code-block :: python
68+
69+ import pygame
70+
71+ window1 = pygame.Window(position = (0 ,100 ))
72+ window2 = pygame.Window(position = (700 ,100 ))
73+
74+ while True :
75+ for event in pygame.event.get():
76+ if event.type == pygame.WINDOWCLOSE :
77+ id = event.window.id
78+ print (f " WINDOWCLOSE event sent to Window # { id } . " )
79+ event.window.destroy()
80+
81+ if event.type == pygame.QUIT :
82+ print (f " Last window is destroyed. QUIT event was sent. " )
83+ pygame.quit()
84+ raise SystemExit
85+
4786 .. versionadded :: 2.4.0
4887 .. versionchanged :: 2.5.0 when ``opengl`` is ``True``, the ``Window`` has an OpenGL context created by pygame
4988 .. versionchanged :: 2.5.1 Window is now a base class, allowing subclassing
You can’t perform that action at this time.
0 commit comments