views:

261

answers:

3

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?

+3  A: 

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

SilentGhost
+2  A: 

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

+1  A: 

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.

Toni Ruža