Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Reminder
I was trying to create reminder based on scheduled time. I used classes for switching among pages.
The idea of hole program is: First page - select the user (add new or delete existing)
Second Page - add exacat time for selected user
Third page - keep it open and if the real (current time) is equal to scheduled time of selected user,
the program remind you with messagebox - It's time to take the pills (for example)
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.timeFrame.after(200, self.updateTime)
        self.checkReminds() #call the second function

    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:
Traceback (most recent call last): File "D:\Python\School\CoronaTime\Corona Time -", line 301, in <module> app = Application() File "D:\Python\School\CoronaTime\Corona Time -", line 23, in __init__ frame = F(container, self) File "D:\Python\School\CoronaTime\Corona Time -", line 273, in __init__ self.updateTime() File "D:\Python\School\CoronaTime\Corona Time -", line 281, in updateTime self.checkReminds() File "D:\Python\School\CoronaTime\Corona Time -", 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?
none of the line numbers in error are shown in code.
can't see where selectedValue is defined.

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)