howto do a robust simple cross platform beep

Chris Angelico rosuav at gmail.com
Tue Jul 24 23:52:27 CEST 2012


On Wed, Jul 25, 2012 at 7:39 AM, Gelonida N <gelonida at gmail.com> wrote:
> On 07/15/2012 03:15 AM, rantingrickjohnson at gmail.com wrote:> On Friday, July
> 13, 2012 8:00:05 PM UTC-5, gelonida wrote:
>>> I just want to use a beep command that works cross platform. [...] I
>>> just want to use them as alert, when certain events occur within a
>>> very long running non GUI application.
>>
>> I can see a need for this when facing a non GUI interface.
> That's exactly my usecase.
> A rather tiny script running for hours and telling the users when results
> are ready.

Sounds reasonable. I'd be inclined to solve just my own problem,
though; work it out for the platforms you use, and don't worry too
much about the rest. But that's because I'm lazy :)

> Could I use github (as O know git already)?

You certainly could, though that doesn't help with the whole "building
a module" part. (And I can't help there either, never done it. Sorry.)

There are quite a few ways of creating an alert such as you describe.
The easiest way may be to play a .WAV file rather than a system beep;
there are a number of different options on different platforms, so
your module could be written in pure Python and basically wrap the
whole lot up into a huge bunch of "except ImportError" checks. Here's
a few ways:

http://stackoverflow.com/questions/307305/play-a-sound-with-python

Burying all that complexity behind a simple "play_sound()" function
would be handy, and you could easily start with just 2-3 options and
add more later.

ChrisA



More information about the Python-list mailing list