from tkinter import* from math import pi,sin,cos class Application(Tk): def __init__(self): Tk.__init__(self) self.can1 = Canvas(self,bg='white', height=HEIGHT,width=WIDTH) self.can1.pack(side=LEFT) Systeme.__init__(self,1,1,1, 0,1) #s_sol = Systeme() #s1 =Scale(self, label='Echelle', from_=1, to=100, command=self.Soleil.echelle_planete) #s1.pack(side=LEFT, pady =5, padx =20) #s1.set(1) class Astre(): def __init__(self,pos,d,r,coul,v=0.1,ech_ua=1/10000,ech_pla=1/10,ech_sol=1, masse=0): # Position init, distance du centre, rayon de l'astre, couleur, masse, vitesse orbitale self.pos = pos self.d = d self.r = r self.couleur = coul self.ech_ua,self.ech_pla,self.ech_sol=ech_ua,ech_pla,ech_sol self.v = v self.angle = 0 self.x1,self.y1= x-self.d*self.ech_ua,y # coordonnées initiale du centre d'un astre self.dess_planete= pos.create_oval(self.x1-self.r*self.ech_pla,self.y1-self.r*self.ech_pla,self.x1+self.r*self.ech_pla,self.y1+self.r*self.ech_pla, width=1, fill=self.couleur) self.pos.create_oval(x-self.d*self.ech_ua,y-self.d*self.ech_ua,x+self.d*self.ech_ua,y+self.d*self.ech_ua, width=1, outline='light grey') # calcul de l'orbite def move(self): self.angle = self.angle + self.v/10 self.vy = x + self.d*self.ech_ua*sin(self.angle) self.vx = y + self.d*self.ech_ua*cos(self.angle) self.pos.coords(self.dess_planete,self.vx-self.r*self.ech_pla,self.vy+self.r*self.ech_pla,self.vx+self.r*self.ech_pla,self.vy-self.r*self.ech_pla) self.pos.after(30,self.move) def echelle_planete(self,coef=1): self.ech_pla = 1/int(coef) self.pos.coords(self.dess_planete,self.x1-self.r*self.ech_pla,self.y1-self.r*self.ech_pla,self.x1+self.r*self.ech_pla,self.y1+self.r*self.ech_pla) self.pos.create_oval(x-self.d*self.ech_ua,y-self.d*self.ech_ua,x+self.d*self.ech_ua,y+self.d*self.ech_ua, width=1, outline='light grey') # calcul de l'orbite class Systeme(Astre): def __init__(self,ech_ua,ech_pla,ech_sol1, masse,val): self.Soleil= Astre(self.can1, 0 ,70 , 'yellow' , 0.1,1/10000,1/100) self.Mercure= Astre(self.can1, 0.4*150000+700 ,2.45, 'maroon', 0.1) self.Venus= Astre(self.can1, 0.7*150000+700 ,6.3, 'green', 0.08) self.Terre= Astre(self.can1, 1*150000+700 ,6.4, 'blue', 0.3) self.Mars= Astre(self.can1, 1.5*150000+700 ,6 , 'orange', 0.35) self.Jupiter = Astre(self.can1, 5.2*150000+700 ,70, 'orange', 0.42) self.Saturne = Astre(self.can1, 9.5*150000+700 ,60, 'red', 0.51) self.Uranus = Astre(self.can1, 19.6*150000+700 ,25, 'red', 0.44) self.Neptune = Astre(self.can1, 30*150000+700 ,24, 'red', 0.55) self.Jupiter.move() self.Mercure.move() self.Venus.move() self.Terre.move() self.Mars.move() self.Jupiter.move() self.Saturne.move() self.Uranus.move() self.Neptune.move() self.val = val def echelle_systeme(self): pass class echelle(): """détermine échelle spatiale""" def __(self,echelle = 1,ech_sol=1000,ech_plan=10,UA=150): pass #variables HEIGHT = 800 WIDTH = 800 x,y=HEIGHT/2,WIDTH/2 fen = Application() fen. mainloop