just a beep

L

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
 
L

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
 
F

Fredrik Lundh

Leo said:
so again: is there a more robust and terminal independent way to
generate a 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>
 
F

Fredrik Lundh

Leo said:
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:

</F>
 
V

Vladimir Ivanov

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
If You attempt to use your script only under windows you should try this:
import Winsound
Winsound.Beep(frequency, duration)

-- best regards
Vladimir Ivanov
 
L

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
 
M

Michael Peuser

Leo said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top