osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

System Beep?


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