First of excused my poor coding skills. Just started learning about a week ago
Anyway, I'm trying to right now create a GUI for this weather/clock thing for a project. Right now I need it so that the GUI, I was thinking of using Tkinter, updates every second and basically pulled strings from this program. Currently, the program calculates the time of sunrise and sunset and lunar cycle.
I tried two ways so far, the first method, running the entire program under one script, but it doesn't work due to the mainloop() prevent the calculation from repeating itself for the next day.
So now I was hoping to separate the program into two parts. One with the calculations and the other as the main GUI program. So what I did was basically.
Simplified Calculation Script (Its very long so I write the important part):
its day.py
import datetime
import math
import schedule
import astral
a = Astral()
def tick():
d = datetime.datetimee.today()
second = d.second
minutes = d.minute
hour = d.hour
month = d.month
print(str(hour) + ":" + str(minute) + ":" + str(second))
def mooninfo():
global percent_illuminate
global moon_phase
moon_phase = a.moon_phase(date=datetime.date(year,month,day)
percent_illuminate = VERY LONG EQUATIONS
print("Moon is at... " + str(moon_phase))
print(percent_illuminate)
schedule.every(1).second.do(tick)
schedule.every().day.do(mooninfo)
while True:
schedule.run_pending()
And for the tkinter script I tried
from day import moon_phase
Instead of just importing the moon_phase it started to run the program printing out the time of day nonstop.
So if anyone could help me
- Let the tkinter script update everytime the different variable, second, minutes, hour, day, month, and moon_phase changed.
- Or is there a way to get around the mainloop() of tkinter and just make it run while True: loop too?
- Or any other better way to do it.
I saw that you can let Tkinter track the time making a digital clock of the sort but I need the calculations and also I am also sending variables over to an Arduino too (But I already figured that out).
Any help is greatly appreciated, thanks