473,372 Members | 924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 31777
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: #Hai | last post by:
Hi, I want to throw out a series of 'beep..beep..beep' to the speaker. How to do that ? Thanks
8
by: Marcia Gulesian | last post by:
How can I create a beep in javascript (I.E. 5.5 +) ?
1
by: Hai Ly Hoang | last post by:
Hi, I want to make a beep (like MS-DOS beep, not a beep from sound-card). How to do that ? Thanks
2
by: Hai Ly Hoang | last post by:
Hi, I want to make a beep from PC speaker (like C++ beep(), not a beep from sound-card). How to do that ? Thanks
3
by: Thom Little | last post by:
The following code will produce a sound in C# ... using System.Runtime.InteropServices; Beep( 500, 500 ); private static extern bool Beep( int freq, int dur ); How can I play the sound...
4
by: Kartic | last post by:
Hi, My program needs to open another form(Form2) at form1 load. But Form2 always opens with a beep. How do I get rid of that beep. I tried to load form2 from Form1 activate also but with no...
4
by: Rich | last post by:
Hello, I want to use the Beep() to alert users about certain messages but in my workstation I can't get a sound out of it. But Beep works in VB6. What do I need to do? Sub... .... Beep()...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
When I press the Enter key in a Textbox I get a beep sound. But when I press the Enter key in a combobox, I don't get the beep sound. Is there a way to suppress the beep? How to do this? ...
2
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
I have a tabcontrol where I want to capture the CTRL+C key combination. My tabcontrol has on its tabpages some treeView controls. My intention is to intercept the event of pressing the CTRL+C when...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.