I couldn't finish my post so, here is the rest.
I created two functions:
def updateTime(self):
#global selectedValue
self.digitTime = time.strftime("%H:%M")
self.timeLabel.configure(text=self.digitTime)
self.timeFrame.after(200, self.updateTime)
self.checkReminds() #call the second function
and
def checkReminds(self):
global selectedValue
with open(filepath, "r") as f:
for line in f:
if selectedValue in line:
result = re.findall(r";(.*?);", line)
print(f"Result: {result}")
for splited in result:
print(f"Splited: {splited}")
print(f"Now: {self.digitTime}")
if splited == self.digitTime:
print(f"Yes {splited} == {self.digitTime}")
messagebox.showinfo("It's Time", "Take the pills")
First function is getting the real time (current).
Second function is getting the name of the user from first page and save it to the varriable "selectedValue" (also time from second page).
The error comes when i run the code:
Error:
Traceback (most recent call last):
File "D:\Python\School\CoronaTime\Corona Time - clear.py", line 301, in <module>
app = Application()
File "D:\Python\School\CoronaTime\Corona Time - clear.py", line 23, in __init__
frame = F(container, self)
File "D:\Python\School\CoronaTime\Corona Time - clear.py", line 273, in __init__
self.updateTime()
File "D:\Python\School\CoronaTime\Corona Time - clear.py", line 281, in updateTime
self.checkReminds()
File "D:\Python\School\CoronaTime\Corona Time - clear.py", line 288, in checkReminds
if selectedValue in line:
NameError: name 'selectedValue' is not defined
But I find out, if i call the second function with pushing any button on the third site, the function works, but it's not what i wanted to. Because this function runs only one time, when i push the button. The idea is that whenever is scheduled time equal to the current time, the message box appears. I want to compare the the scheduled time, which was added at the other page with the current. I hope it was clear enough.
Has anyone idea, why it is not working or is there any easier solution?