System Beep?
Chris Angelico
rosuav at gmail.com
Tue Mar 12 09:52:25 EDT 2019
On Wed, Mar 13, 2019 at 12:16 AM <ssmitch at gmail.com> wrote:
>
> On Saturday, March 9, 2019 at 12:53:35 AM UTC-5, Terry Reedy wrote:
> > On 3/8/2019 1:13 PM, Steve wrote:
> > > How can I cause a system beep using code?
> >
> > >>> import winsound as ws
> > >>> ws.Beep(500, 1000)
> >
> > and
> >
> > >>> from tkinter import Tk
> > >>> root = Tk()
> > >>> root.bell()
> >
> > work for me. The bell is not exactly a bell, but different from a
> > monotone beep.
> >
> > --
> > Terry Jan Reedy
>
> Another way that works (at least in Python 2.7) is
> >>> import winsound
> >>> winsound.MessageBeep(-1)
>
> Not exactly a beep, but definitely a pleasant alert.
Something to be careful of is that the message beep is controlled by
the user's sound configs (along with warning, error, etc). This may
include it having no audio attached to it at all. If your intention is
"tell the user there's a message", then by all means, use it; but
otherwise, you may want to stick with winsound.Beep.
ChrisA
More information about the Python-list
mailing list