Python Forum
[Tkinter] Sound notification issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Sound notification issue
#1
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
Reply
#2
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)
Reply
#3
(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.
Larz60+ write Dec-17-2024, 10:17 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Tags added this time. Please use when making future posts.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  notification from database iFunKtion 3 4,294 Mar-13-2017, 04:18 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020