1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| from Tkinter import *
import time
from time import gmtime, strftime
def tick(): #fonction permettant l'horloge de se mettre a jour chaque seconde
global time1
time2 = time.strftime('%H:%M:%S')
if time2 != time1:
time1=time2
clock.config(text=time2)
clock.after(200, tick)
def bxl(): #fonction affichant l'heure de Bruxelles
global time1
time2 = time.strftime('%H:%M:%S')#Commande #prenant l'heure local
if time2 != time1:
time1 = time2
clock.config(text=time2)
clock.after(200, bxl)
tick()
def ny():
global time1
time2 = time.strftime('%H:%M:%S +7200')#L'erreur #est à coup sur ici. Je ne suis pas sur pour le 7200 qui je pensais me #permettrait de rajouter un certain nombre de secondes
if time2 != time1:
time1 = time2
clock.config(text=time2)
clock.after(200, bxl)
tick()
fen1=Tk()
fen1.title("Horloge du monde")
time1 = ''
tex1 = Label(fen1, text='Bienvenue à vous !', fg='purple')
tex1.pack()
clock = Label(fen1, font=('times', 20, 'bold'), bg='orange')
clock.pack(fill=BOTH, expand=1)
bou1 = Button(fen1, text="Afficher l'heure de Bruxelles", command = bxl)
bou1.pack()
bou2 = Button(fen1, text="Afficher l'heure de New-York", command = ny)
bou2.pack()
bou3 = Button(fen1,text="Quitter", command = fen1.destroy)
bou3.pack()
fen1.mainloop() |
Partager