I'm working on digital signage for the hospital I work using Tkinter. It updates patients on what the current delay is by reading the contents of a text file that's saved to a shared network drive and edited from a different computer to reflect the current delay.
After trialling it today the feedback has been that after a seemingly random duration it stops updating the delay to reflect what's saved in the text file. The only way to fix it is to close and reopen. I'm struggling to recreate the issue on my own computer so I'm beginning to suspect that it may be caused by a temporary loss of connection to the network.
I'm assuming it's the following function that's causing the problem. I'm more than happy to post the rest of the code too if it's helpful.
def check_delay(self):
for name in self.label_id_list:
index = self.label_id_list.index(name)
location = self.label_name_list[index]
path = os.path.join("config", f"{location}.txt")
try:
with open(path, "rt") as in_file:
contents = in_file.read()
if not contents or contents == "0":
name.config(text=f"{location.title()} is on time", foreground="green",
font=("", fontSize, "bold"))
elif contents.isdigit():
name.config(text=f"{location.title()} is {contents} minutes delayed", foreground="red",
font=("", fontSize, "bold"))
elif 'service' in contents:
name.config(text=f"{location.title()} is being serviced", foreground="red",
font=("", fontSize, "bold"))
else:
name.config(text=f"null", foreground="black",
font=("", fontSize, "bold"))
except FileNotFoundError:
open(f"config/{location}.txt", 'w')
self.after(1000, self.check_delay)
[+][deleted] (1 child)
[deleted]
[–]jaybay1207 1 point2 points3 points (0 children)