"""
Animation d'une éclipse avec les touches de direction
éclipse de soleil totale visible en France le 3 septembre 2081
éclipse complète le 23 septembre 2090
éclipse solaire partielle visibles en France le 29 mars 2025 et le 12 août 2026
"""
from tkinter import *
import math
import ephem
o=ephem.Observer()
o.date='2023/10/14 17:55:00' # UTC eclipse de soleil
o.date='2081/09/03 06:35:00' # UTC eclipse de soleil
o.date='2090/09/23 16:44:00' # UTC eclipse de soleil
o.date='1999/08/11 09:15:00' # UTC eclipse de soleil
#o.lat='48.866667' # latitude pour Paris
#o.lon= '2.333333' # longitude pour Paris
#o.elevation=-6371000 # observateur au centre de la terre
o.lat='43.7' # Nice
o.lon= '7.23' # Nice
o.elevation=0 # en mètre
zoom=900
h=3*180
w=h # 3*360
w2=w//2
h2=h//2
couleurs=['red','black'] # soleil, lune
def zodiaque(t):
if t=="Ari":return "♈"# Bélier
if t=="Tau":return "♉"# Taureau
if t=="Gem":return "♊"# Gémeaux
if t=="Cnc":return "♋"# Cancer
if t=="Leo":return "♌"# Lion
if t=="Vir":return "♍"# Vierge
if t=="Lib":return "♎"# Balance
if t=="Sco":return "♏"# Scorpion
if t=="Sgr":return "♐"# Sagittaire
if t=="Cap":return "♑"# Capricorne
if t=="Aqr":return "♒"# Verseau
if t=="Psc":return "♓"# Poisson
def circle(n):
global h2,w2,astres,o
ast=astres[n]
constel=ephem.constellation(ast)[0]
x=math.degrees(ast.az-astres[0].az)
y=math.degrees(ast.alt-astres[0].alt)
diametre=ast.size * 0.000277778 # en seconde " traduit en °
rayon=diametre/2
rayon*=zoom
print(x,'°,',y,'°,',diametre,zodiaque(constel),constel,o.date,'UTC',math.degrees(astres[n].elong),'°')
x*=zoom
y*=zoom
x1=w2+(x-rayon)
y1=h2-(y-rayon)
x2=w2+(x+rayon)
y2=h2-(y+rayon)
cnvs.create_oval(x1,y1,x2,y2,fill=couleurs[n],outline=couleurs[n])
def affiche():
global o,astres,drapeau #drapeau pour ne pas chevaucher les events key, b1 et b2
fen.title(ephem.localtime(o.date).strftime("%d/%m/%Y %H:%M:%S"))
print(o.date)
astres=[ephem.Sun(o),ephem.Moon(o)]
cnvs.delete('all')
for n in range(2):circle(n)
drapeau=False
def key(e):
global drapeau,o
if drapeau:return
drapeau=True
if(e.keysym=='Left'):o.date-=ephem.second
elif(e.keysym=='Right'):o.date+=ephem.second
elif(e.keysym=='Up'):o.date+=ephem.minute
elif(e.keysym=='Down'):o.date-=ephem.minute
elif(e.keysym=='space'):o.date=ephem.now()
elif(e.keysym=='j+'):o.date+=24*ephem.hour
elif(e.keysym=='j-'):o.date-=24*ephem.hour
elif(e.keysym=='a'):o.date-=8760*ephem.hour
elif(e.keysym=='A'):o.date+=8760*ephem.hour
else:
drapeau=False
return
print()
affiche()
def b1(e):
e.keysym='j-'
key(e)
def b3(e):
e.keysym='j+'
key(e)
fen = Tk()
fen.bind("<Key>",key)
#fen.bind('<Button-1>',b1)
#fen.bind('<Button-3>',b3)
cnvs=Canvas(fen,width=w,height=h)
cnvs.pack()
""""""
def Nice():
o.lat='43.7'
o.lon= '7.25'
o.elevation=0
print('nNice',o.lon,o.lat)
affiche()
return
def Paris():
o.lat='48.866667'
o.lon= '2.333333'
o.elevation=0
print('nParis',o.lon,o.lat)
affiche()
return
def Centre():
o.lat='0.0'
o.lon='0.0'
o.elevation=-6371000
print('nCentre de la terre')
affiche()
return
def _1999():
o.date='1999/08/11 09:15:00'
affiche()
return
def _2023():
o.date='2023/10/14 17:55:00'
affiche()
return
def _2081():
o.date='2081/09/03 06:35:00'
affiche()
return
def _2090():
o.date='2090/09/23 16:44:00'
affiche()
return
def maintenant():
o.date=ephem.now()
affiche()
return
menu_bar=Menu(fen)
menu_file = Menu(menu_bar, tearoff=0)
menu_file.add_command(label="Observateur au centre de la terre",underline=0,accelerator="O",command=Centre)
menu_file.add_command(label="Nice",underline=0,accelerator="N",command=Nice)
menu_file.add_command(label="Paris",underline=0,accelerator="P",command=Paris)
menu_file.add_separator()
menu_file.add_command(label="1999",underline=0,accelerator="1",command=_1999)
menu_file.add_command(label="2023",underline=0,accelerator="2",command=_2023)
menu_file.add_command(label="2081",underline=0,accelerator="8",command=_2081)
menu_file.add_command(label="2090",underline=0,accelerator="9",command=_2090)
menu_file.add_command(label="Maintenant",underline=0,accelerator="M",command=maintenant)
menu_file.add_separator()
menu_file.add_command(label="Quitter",underline=0,accelerator="Q",command=fen.destroy)
menu_bar.add_cascade(label="Choix",underline=0,accelerator="Alt+C",menu=menu_file)
fen.config(menu=menu_bar)
""""""
affiche()
fen.mainloop()
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.