Python Forum

Full Version: Sound notification issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Greetings,

I have designed an app, in tkinter, that pulls live incident (call) data from my local fire department. My goal for this app is to be notified of a specific call type. My app does meet this purpose. I have that specific call type (row), shown in a treeview, change colors so it is easily recognized as well as it plays a sound, using "winsound". However, since this app refreshes call data every 45 seconds, as long as that specific call is still active, it plays a sound every 45 seconds. My goal is to be notified once for each occurrence of the call type. If the data was static, I could accomplish this easily, but since the data is updated every 45 seconds, I am not sure if this is even possible. Any suggestions?

Thank you in advance,
Kevin
Please post enough of your code to describe what the call data looks like and how you play a sound based on the call type.

Your program needs to keep track of the previous call data when updating with the new. Only play the sound when the new data call type does not match the old. Something like:
previous_calls = call_data.copy()
call_data = update_call_data()
for call in call_data:
    if call.type in notification_types and not call in previous_calls:
        play_sound(call.type)
(Dec-16-2024, 01:01 PM)deanhystad Wrote: [ -> ]Please post enough of your code to describe what the call data looks like and how you play a sound based on the call type.

Sorry for not including the code

f
or row in rows:
                if row[0] == "MU":
                    tree.insert("", END, values = row, tag = 'MU') # adds the line color change tag
                    winsound.PlaySound("sound.wav",winsound.SND_ASYNC)
                                                           
                else:
                    tree.insert("", END, values = row)
I will try to figure out how to create the copy to compare the old data with the new.