Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import tkinter as tk
- def convertir_a_C():
- caja_gradosC.delete(0,tk.END)
- temp = (float(caja_gradosF.get()) - 32) / 1.8
- caja_gradosC.insert(1,f"{temp:.1f}")
- def convertir_a_F():
- caja_gradosF.delete(0,tk.END)
- temp = float(caja_gradosC.get()) * 1.8 + 32
- caja_gradosF.insert(1,f"{temp:.1f}")
- ventana= tk.Tk()
- ventana.config(width=500, height=150)
- ventana.resizable(0,0)
- ventana.title("Conversor de grados ° ")
- #ventana.iconbitmap("nombre del icono .ico")
- # Campo grados C°
- etiqueta = tk.Label(text="Grados C°")
- etiqueta.place(x=40, y=30)
- caja_gradosC = tk.Entry()
- caja_gradosC.place(x=110, y=30, width=80, height=25)
- # Campo grados F°
- etiqueta = tk.Label(text="Grados F°")
- etiqueta.place(x=280, y=30)
- caja_gradosF = tk.Entry()
- caja_gradosF.place(x=350, y=30, width=80, height=25)
- # Creo un botón C° A F°
- boton = tk.Button(text="C°>>F°", command=convertir_a_F)
- boton.place(x=80, y=90, width=80, height=25)
- # Creo un botón F° A C°
- boton = tk.Button(text="F°>>C°", command=convertir_a_C)
- boton.place(x=320, y=90, width=80, height=25)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement