just a beep

Discussion in 'Python' started by Leo, Sep 2, 2003.

  1. Leo

    Leo Guest

    hi there

    i want python to do a beep.

    in the docu i found in tkinter the method
    bell()
    but the script:
    import Tkinter
    Tkinter.bell()
    gives the error:
    AttributeError: 'module' object has no attribute 'bell'

    so how can i make python beep? (maybe even without the tkinter overhead?)

    cheers, leo
     
    Leo, Sep 2, 2003
    #1
    1. Advertising

  2. Leo

    Leo Guest

    beep is not genrated by python (was Re: just a beep)

    hi there

    neither print chr(7) nor print "\a" works, when you execute the script
    directly under windows. (and executing under emacs doesn't work either.)

    it seems that the beep is not generated by python itself but by the
    terminal emulation.

    so again: is there a more robust and terminal independent way to
    generate a beep?

    cheers, leo

    Nick Welch wrote:
    > On Tue, Sep 02, 2003 at 10:17:02AM +1000, DG wrote:
    >
    >>print chr(7)
    >>
    >>:)

    >
    >
    > print "\a" # too
    >
    > :)
    >
     
    Leo, Sep 2, 2003
    #2
    1. Advertising

  3. Re: beep is not genrated by python (was Re: just a beep)

    "Leo" wrote:

    > so again: is there a more robust and terminal independent way to
    > generate a beep?


    on windows, use winsound.Beep:

    >>> import winsound
    >>> help(winsound.Beep)

    Help on built-in function Beep:

    Beep(...)
    Beep(frequency, duration) - a wrapper around the Windows Beep API

    The frequency argument specifies frequency, in hertz, of the sound.
    This parameter must be in the range 37 through 32,767.
    The duration argument specifies the number of milliseconds.
    On WinNT and 2000, the platform Beep API is used directly. Else funky
    code doing direct port manipulation is used; it's unknown whether that
    will work on all systems.

    </F>
     
    Fredrik Lundh, Sep 2, 2003
    #3
  4. "Leo" wrote:

    > i want python to do a beep.
    >
    > in the docu i found in tkinter the method
    > bell()
    > but the script:
    > import Tkinter
    > Tkinter.bell()
    > gives the error:
    > AttributeError: 'module' object has no attribute 'bell'


    you might find it easier to use Python if you spend some time reading
    up on functions vs. methods; in the meantime, here's one way to call
    the "bell" method in Tkinter:

    >>> import Tkinter
    >>> Tkinter.Tk().bell()


    </F>
     
    Fredrik Lundh, Sep 2, 2003
    #4
  5. Re: beep is not genrated by python (was Re: just a beep)

    On Tue, 02 Sep 2003 13:06:00 +1000, Leo <> wrote:

    > hi there
    >
    > neither print chr(7) nor print "\a" works, when you execute the script directly under windows. (and executing under emacs doesn't work either.)
    >
    > it seems that the beep is not generated by python itself but by the terminal emulation.
    >
    > so again: is there a more robust and terminal independent way to generate a beep?
    >
    > cheers, leo
    >
    > Nick Welch wrote:
    >> On Tue, Sep 02, 2003 at 10:17:02AM +1000, DG wrote:
    >>
    >>> print chr(7)
    >>>
    >>> :)

    >>
    >>
    >> print "\a" # too
    >>
    >> :)
    >>

    >

    If You attempt to use your script only under windows you should try this:
    import Winsound
    Winsound.Beep(frequency, duration)

    -- best regards
    Vladimir Ivanov
     
    Vladimir Ivanov, Sep 2, 2003
    #5
  6. Leo

    Leo Guest

    thanks a lot! that's what i want: an platform independend beep!

    and indeed i want to read more about functions vs methods! but my quick
    browse through the docu did not show me that there is sth in beetween
    Tkinter and bell...

    cheers, leo
    "Fredrik Lundh" <> wrote in message
    news:...
    > "Leo" wrote:
    >
    > > i want python to do a beep.
    > >
    > > in the docu i found in tkinter the method
    > > bell()
    > > but the script:
    > > import Tkinter
    > > Tkinter.bell()
    > > gives the error:
    > > AttributeError: 'module' object has no attribute 'bell'

    >
    > you might find it easier to use Python if you spend some time reading
    > up on functions vs. methods; in the meantime, here's one way to call
    > the "bell" method in Tkinter:
    >
    > >>> import Tkinter
    > >>> Tkinter.Tk().bell()

    >
    > </F>
    >
    >
    >
    >
     
    Leo, Sep 3, 2003
    #6
  7. "Leo" <> schrieb im Newsbeitrag
    news:bj3ug3$23m5$...
    > thanks a lot! that's what i want: an platform independend beep!
    >
    > and indeed i want to read more about functions vs methods! but my quick
    > browse through the docu did not show me that there is sth in beetween
    > Tkinter and bell...


    Of course it did not! Have you ever used mainloop() or after(..) ?
    Kindly
    Michael P
     
    Michael Peuser, Sep 5, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. YeeCN

    How to beep or play any sound?

    YeeCN, May 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    555
    Guest
    May 13, 2004
  2. Jenny K

    Re: beep (bell)

    Jenny K, Aug 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    639
    Jerry Hammond
    Aug 30, 2003
  3. =?Utf-8?B?bWc=?=

    Beep in javascript

    =?Utf-8?B?bWc=?=, Apr 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    5,311
    Curt_C [MVP]
    Apr 12, 2004
  4. =?Utf-8?B?QXJuZQ==?=

    beep in the browser

    =?Utf-8?B?QXJuZQ==?=, Dec 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,895
    Steve C. Orr [MVP, MCSD]
    Dec 8, 2004
  5. =?Utf-8?B?QXJuZQ==?=

    Beep

    =?Utf-8?B?QXJuZQ==?=, Dec 9, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    4,961
    Eliyahu Goldin
    Dec 11, 2005
Loading...

Share This Page