Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > just a beep

Reply
Thread Tools

just a beep

 
 
Leo
Guest
Posts: n/a
 
      09-02-2003
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


 
Reply With Quote
 
 
 
 
Leo
Guest
Posts: n/a
 
      09-02-2003
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
>
>
>


 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      09-02-2003
"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>




 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      09-02-2003
"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>




 
Reply With Quote
 
Vladimir Ivanov
Guest
Posts: n/a
 
      09-02-2003
On Tue, 02 Sep 2003 13:06:00 +1000, Leo <(E-Mail Removed)> 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

 
Reply With Quote
 
Leo
Guest
Posts: n/a
 
      09-03-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "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>
>
>
>
>



 
Reply With Quote
 
Michael Peuser
Guest
Posts: n/a
 
      09-05-2003

"Leo" <(E-Mail Removed)> schrieb im Newsbeitrag
news:bj3ug3$23m5$(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mac LC475 (Quadra 650) plays "beep beep beep beep" Uplink Computer Information 0 04-12-2006 10:37 PM
How to beep or play any sound? YeeCN ASP .Net 1 05-13-2004 08:14 AM
just one beep Jacqueline Alexander Computer Support 6 09-25-2003 07:51 AM
Re: beep (bell) Jenny K ASP .Net 1 08-30-2003 04:50 AM
BEEP! BEEP! BEEP! Arg! :( Kevin Low Computer Information 0 07-06-2003 08:29 AM



Advertisments