| 12
 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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 
 | # -*- coding: cp1252 -*-
from Tkinter import*
 
# Création de la fenêtre
 
F = Tk()
w = Frame(F, height=500, width=500)
 
# Affichage de la fenêtre
 
w.pack()
 
## Programme Principal ##
# Convertion de Celsius en Fahrenheit
def CelToFah(celsius) :
    reponse= 9./5.*celsius+32
    text3.config(text=reponse)
    return reponse
 
##################################
# Convertion de Celsius en Kelvin
def CelToKel(celsius) :
    kelvin= celsius+273.15
    return kelvin
 
######################################
# Convertion de Fahrenheit en Celsius
def FahToCel(fahrenheit) :
    celsius= 5./9.*(fahrenheit-32)
    return celsius
 
##################################
# Convertion de Kelvin en Celsius
def KelToCel(kelvin) :
    celsius= kelvin-273.15
    return celsius
 
##################################
# Convertion de Fahrenheit en Kelvin
def FahToKel(fahrenheit) :
    kelvin= 5./9.*(fahrenheit+459.67)
    return kelvin
 
##################################
# Convertion de Kelvin en Fahrenheit
def KelToFah(kelvin) :
    fahrenheit= 9./5.*(kelvin-459.67)
    return fahrenheit
 
# Création de boutons
 
quitBouton = Button(F, text='Quitter', anchor=SE, command=F.quit)
quitBouton.pack(side=BOTTOM, anchor=SE)
Bouton1 = Button(F, text='CelToFah', anchor=SE, command=CelToFah)
Bouton1.pack(side=BOTTOM, anchor=SW)
Bouton2 = Button(F, text='CelToKel', anchor=SW, command=CelToKel)
Bouton2.pack(side=BOTTOM, anchor=SW)
Bouton3 = Button(F, text='KelToFah', anchor=SW, command=KelToFah)
Bouton3.pack(side=BOTTOM, anchor=SW)
Bouton4 = Button(F, text='KelToCel', anchor=SW, command=KelToCel)
Bouton4.pack(side=BOTTOM, anchor=SW)
Bouton5 = Button(F, text='FahToCel', anchor=SW, command=FahToCel)
Bouton5.pack(side=BOTTOM, anchor=SW)
Bouton6 = Button(F, text='FahToKel', anchor=SW, command=FahToKel)
Bouton6.pack(side=BOTTOM, anchor=SW)
 
# Création du texte d'entête
 
texte1=Label(w,text="Convertisseur température")
texte1.pack()
 
# Création de l'entrée
 
texte2 = Label(w, text = 'Entrez la Temperature :', anchor=SW)
entree = Entry(w)
texte2.pack(anchor=SW)
entree.pack(anchor=SW)
 
 
w.mainloop() | 
Partager