469,352 Members | 1,766 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

just a beep

Leo
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
Jul 18 '05 #1
6 31214
Leo
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

:)


Jul 18 '05 #2
"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>


Jul 18 '05 #3
"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>


Jul 18 '05 #4
On Tue, 02 Sep 2003 13:06:00 +1000, Leo <ha*************@NOSPAM.gmx.net> 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

Jul 18 '05 #5
Leo
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" <fr*****@pythonware.com> wrote in message
news:ma*********************************@python.or g...
"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>

Jul 18 '05 #6

"Leo" <le********@NOSPAM.isys.com.au> schrieb im Newsbeitrag
news:bj***********@otis.netspace.net.au...
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
Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by #Hai | last post: by
8 posts views Thread by Marcia Gulesian | last post: by
1 post views Thread by Hai Ly Hoang | last post: by
2 posts views Thread by Hai Ly Hoang | last post: by
3 posts views Thread by Thom Little | last post: by
4 posts views Thread by Kartic | last post: by
4 posts views Thread by =?Utf-8?B?UmljaA==?= | last post: by
2 posts views Thread by =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.