Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit00a9844

Browse files
authored
gh-131453: Add additional constants to winsound module (GH-131454)
1 parenta2ea417 commit00a9844

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

‎Doc/library/winsound.rst‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,27 @@ provided by Windows platforms. It includes functions and several constants.
142142
to specify an application-defined sound alias.
143143

144144

145+
..data::SND_SENTRY
146+
147+
Triggers a SoundSentry event when the sound is played.
148+
149+
..versionadded::3.14
150+
151+
152+
..data::SND_SYNC
153+
154+
The sound is played synchronously. This is the default behavior.
155+
156+
..versionadded::3.14
157+
158+
159+
..data::SND_SYSTEM
160+
161+
Assign the sound to the audio session for system notification sounds.
162+
163+
..versionadded::3.14
164+
165+
145166
..data::MB_ICONASTERISK
146167

147168
Play the ``SystemDefault`` sound.
@@ -166,3 +187,30 @@ provided by Windows platforms. It includes functions and several constants.
166187

167188
Play the ``SystemDefault`` sound.
168189

190+
191+
..data::MB_ICONERROR
192+
193+
Play the ``SystemHand`` sound.
194+
195+
..versionadded::3.14
196+
197+
198+
..data::MB_ICONINFORMATION
199+
200+
Play the ``SystemDefault`` sound.
201+
202+
..versionadded::3.14
203+
204+
205+
..data::MB_ICONSTOP
206+
207+
Play the ``SystemHand`` sound.
208+
209+
..versionadded::3.14
210+
211+
212+
..data::MB_ICONWARNING
213+
214+
Play the ``SystemExclamation`` sound.
215+
216+
..versionadded::3.14

‎Lib/test/test_winsound.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ def test_hand(self):
8282
deftest_question(self):
8383
safe_MessageBeep(winsound.MB_ICONQUESTION)
8484

85+
deftest_error(self):
86+
safe_MessageBeep(winsound.MB_ICONERROR)
87+
88+
deftest_information(self):
89+
safe_MessageBeep(winsound.MB_ICONINFORMATION)
90+
91+
deftest_stop(self):
92+
safe_MessageBeep(winsound.MB_ICONSTOP)
93+
94+
deftest_warning(self):
95+
safe_MessageBeep(winsound.MB_ICONWARNING)
96+
8597
deftest_keyword_args(self):
8698
safe_MessageBeep(type=winsound.MB_OK)
8799

@@ -161,6 +173,15 @@ def test_stopasync(self):
161173
# does not raise on systems without a sound card.
162174
winsound.PlaySound(None,winsound.SND_PURGE)
163175

176+
deftest_sound_sentry(self):
177+
safe_PlaySound("SystemExit",winsound.SND_ALIAS|winsound.SND_SENTRY)
178+
179+
deftest_sound_sync(self):
180+
safe_PlaySound("SystemExit",winsound.SND_ALIAS|winsound.SND_SYNC)
181+
182+
deftest_sound_system(self):
183+
safe_PlaySound("SystemExit",winsound.SND_ALIAS|winsound.SND_SYSTEM)
184+
164185

165186
if__name__=="__main__":
166187
unittest.main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Some:data:`!SND_*` and:data:`!MB_*` constants are added to:mod:`winsound`.

‎PC/winsound.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ PyDoc_STRVAR(sound_module_doc,
5656
"SND_NODEFAULT - Do not play a default beep if the sound can not be found\n"
5757
"SND_NOSTOP - Do not interrupt any sounds currently playing\n"// Raising RuntimeError if needed
5858
"SND_NOWAIT - Return immediately if the sound driver is busy\n"// Without any errors
59-
"SND_APPLICATION - sound is an application-specific alias in the registry."
59+
"SND_APPLICATION - sound is an application-specific alias in the registry.\n"
60+
"SND_SENTRY - Triggers a SoundSentry event when the sound is played.\n"
61+
"SND_SYNC - Play the sound synchronously, default behavior.\n"
62+
"SND_SYSTEM - Assign sound to the audio session for system notification sounds.\n"
6063
"\n"
6164
"Beep(frequency, duration) - Make a beep through the PC speaker.\n"
6265
"MessageBeep(type) - Call Windows MessageBeep.");
@@ -232,12 +235,19 @@ exec_module(PyObject *module)
232235
ADD_DEFINE(SND_PURGE);
233236
ADD_DEFINE(SND_LOOP);
234237
ADD_DEFINE(SND_APPLICATION);
238+
ADD_DEFINE(SND_SENTRY);
239+
ADD_DEFINE(SND_SYNC);
240+
ADD_DEFINE(SND_SYSTEM);
235241

236242
ADD_DEFINE(MB_OK);
237243
ADD_DEFINE(MB_ICONASTERISK);
238244
ADD_DEFINE(MB_ICONEXCLAMATION);
239245
ADD_DEFINE(MB_ICONHAND);
240246
ADD_DEFINE(MB_ICONQUESTION);
247+
ADD_DEFINE(MB_ICONERROR);
248+
ADD_DEFINE(MB_ICONINFORMATION);
249+
ADD_DEFINE(MB_ICONSTOP);
250+
ADD_DEFINE(MB_ICONWARNING);
241251

242252
#undef ADD_DEFINE
243253

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp