Python Forum
[Tkinter] Reminder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Reminder
#1
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)
Reply
#2
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?
Reply
#3
none of the line numbers in error are shown in code.
can't see where selectedValue is defined.
Reply


Forum Jump:

User Panel Messages

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