Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cross-platform 'ping' system sound in PyQt5?
Forum Updated to NodeBB v4.3 + New Features

Cross-platform 'ping' system sound in PyQt5?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 449 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    donquibeats
    wrote on last edited by
    #1

    I've got a PyQt5 application that performs a variety of functions, and on some of them (particularly the ones that take some time), I want it to go 'ping' when it's done. i.e. to play the system default ping sound.

    Here's an extract from my code:

    if func.func_environment.is_windows():
        import winsound
    
    def is_windows():
        return platform.system() == "Windows"
    
    def ping():
        if func.func_environment.is_windows():
            winsound.PlaySound("*", winsound.SND_ALIAS | winsound.SND_ASYNC)
        else:
            print("\a")
    

    This is working fine in Windows, using the winsound module, but I can't seem to find an equivalent for Mac that works. The 'terminal sound' ('\a') is doing nothing.

    Does Qt have any built-in cross-platform method for triggering standard system sounds?

    Alternatively, is there a library that will handle this in a nice cross-platform way?

    Or alternatively (again), how should I be handling this on a Mac so that my Qt application, and not the terminal, tries to make a system sound please?

    jsulmJ 1 Reply Last reply
    0
    • D donquibeats

      I've got a PyQt5 application that performs a variety of functions, and on some of them (particularly the ones that take some time), I want it to go 'ping' when it's done. i.e. to play the system default ping sound.

      Here's an extract from my code:

      if func.func_environment.is_windows():
          import winsound
      
      def is_windows():
          return platform.system() == "Windows"
      
      def ping():
          if func.func_environment.is_windows():
              winsound.PlaySound("*", winsound.SND_ALIAS | winsound.SND_ASYNC)
          else:
              print("\a")
      

      This is working fine in Windows, using the winsound module, but I can't seem to find an equivalent for Mac that works. The 'terminal sound' ('\a') is doing nothing.

      Does Qt have any built-in cross-platform method for triggering standard system sounds?

      Alternatively, is there a library that will handle this in a nice cross-platform way?

      Or alternatively (again), how should I be handling this on a Mac so that my Qt application, and not the terminal, tries to make a system sound please?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @donquibeats Why not cross platform (except embedded Linux) https://doc.qt.io/qt-5/qapplication.html#beep ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • D Offline
        D Offline
        donquibeats
        wrote on last edited by
        #3

        Only because I didn't know about it! All my Googling for 'qt', 'pyqt5', 'system', 'sound', and even 'ping' had somehow managed to miss the obvious.

        Thanks for pointing it out!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved