Cross-platform 'ping' system sound in PyQt5?

  • 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)

    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?

  • Lifetime Qt Champion

    @donquibeats Why not cross platform (except embedded Linux) ?

  • 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!

Log in to reply