Python 中的系统标准声音

发布于 2024-08-01 19:58:33 字数 110 浏览 3 评论 0原文

如何从 Python 脚本中播放标准系统声音?

我正在 wxPython 中编写一个 GUI 程序,需要在事件上发出蜂鸣声以吸引用户的注意,也许 wxPython 中有我可以利用的函数?

How play standard system sounds from a Python script?

I'm writing a GUI program in wxPython that needs to beep on events to attract user's attention, maybe there are functions in wxPython I can utilize?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

玩套路吗 2024-08-08 19:58:33

在 Windows 上,您可以使用 winsound 和我想 Unix 上的 curses.beep

on windows you could use winsound and I suppose curses.beep on Unix.

不回头走下去 2024-08-08 19:58:33

文档 中,您可以使用 wx.Bell() 函数(未测试尽管)

from the documentation, you could use wx.Bell() function (not tested though)

£烟消云散 2024-08-08 19:58:33

从文档中:

wxTopLevelWindow::RequestUserAttention

void RequestUserAttention(int flags =
wxUSER_ATTENTION_INFO)

使用依赖于系统的方式来吸引
用户注意窗口时
在后台。

标志的值可以是
wxUSER_ATTENTION_INFO(默认)或
wxUSER_ATTENTION_ERROR 结果
以更激烈的行动。 当在
如有疑问,请使用默认值。

注意这个函数应该
通常仅在以下情况下使用
申请尚未在
前景。

该功能目前已实现
对于 Win32,它会闪烁窗口
任务栏中的图标,以及 wxGTK
任务栏支持它。

From the documentation:

wxTopLevelWindow::RequestUserAttention

void RequestUserAttention(int flags =
wxUSER_ATTENTION_INFO)

Use a system-dependent way to attract
users attention to the window when it
is in background.

flags may have the value of either
wxUSER_ATTENTION_INFO (default) or
wxUSER_ATTENTION_ERROR which results
in a more drastic action. When in
doubt, use the default value.

Note that this function should
normally be only used when the
application is not already in
foreground.

This function is currently implemented
for Win32 where it flashes the window
icon in the taskbar, and for wxGTK
with task bars supporting it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文