just a beep

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leo

    just a beep

    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

    #2
    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:[color=blue]
    > On Tue, Sep 02, 2003 at 10:17:02AM +1000, DG wrote:
    >[color=green]
    >>print chr(7)
    >>
    >>:)[/color]
    >
    >
    > print "\a" # too
    >
    > :)
    >[/color]

    Comment

    • Fredrik Lundh

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

      "Leo" wrote:
      [color=blue]
      > so again: is there a more robust and terminal independent way to
      > generate a beep?[/color]

      on windows, use winsound.Beep:
      [color=blue][color=green][color=darkred]
      >>> import winsound
      >>> help(winsound.B eep)[/color][/color][/color]
      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>




      Comment

      • Fredrik Lundh

        #4
        Re: just a beep

        "Leo" wrote:
        [color=blue]
        > 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'[/color]

        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:
        [color=blue][color=green][color=darkred]
        >>> import Tkinter
        >>> Tkinter.Tk().be ll()[/color][/color][/color]

        </F>




        Comment

        • Vladimir Ivanov

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

          On Tue, 02 Sep 2003 13:06:00 +1000, Leo <halloleo.PLEAS [email protected] t> wrote:
          [color=blue]
          > 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:[color=green]
          >> On Tue, Sep 02, 2003 at 10:17:02AM +1000, DG wrote:
          >>[color=darkred]
          >>> print chr(7)
          >>>
          >>> :)[/color]
          >>
          >>
          >> print "\a" # too
          >>
          >> :)
          >>[/color]
          >[/color]
          If You attempt to use your script only under windows you should try this:
          import Winsound
          Winsound.Beep(f requency, duration)

          -- best regards
          Vladimir Ivanov

          Comment

          • Leo

            #6
            Re: just a beep

            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" <fredrik@python ware.com> wrote in message
            news:mailman.10 62489605.3888.p [email protected] ...[color=blue]
            > "Leo" wrote:
            >[color=green]
            > > 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'[/color]
            >
            > 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:
            >[color=green][color=darkred]
            > >>> import Tkinter
            > >>> Tkinter.Tk().be ll()[/color][/color]
            >
            > </F>
            >
            >
            >
            >[/color]


            Comment

            • Michael Peuser

              #7
              Re: just a beep


              "Leo" <leo.broska@NOS PAM.isys.com.au > schrieb im Newsbeitrag
              news:bj3ug3$23m [email protected] ce.net.au...[color=blue]
              > 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...[/color]

              Of course it did not! Have you ever used mainloop() or after(..) ?
              Kindly
              Michael P


              Comment

              Working...