Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- Conversion de temperatura
- DESAFIO: extender para lograr la conversión de ºC --> ºF
- """
- import tkinter as tk
- def convertir():
- temp = caja_farenheit.get()
- temp = (float(temp) - 32) / 1.8
- caja_celsius.delete(0,tk.END)
- caja_celsius.insert(0,f"{temp:.1f}")
- ventana = tk.Tk()
- ventana.config(width=300, height=150)
- ventana.title("ºF -> ºC")
- # prohibo redimensionar la ventana
- ventana.resizable(False, False)
- etiqueta = tk.Label(text="ºF")
- etiqueta.place(x=10, y=10)
- caja_farenheit = tk.Entry()
- caja_farenheit.place(x=30, y=10, width=50, height=25)
- etiqueta = tk.Label(text="ºC")
- etiqueta.place(x=150, y=10)
- caja_celsius = tk.Entry()
- caja_celsius.place(x=170, y=10, width=50, height=25)
- # BOTON
- boton = tk.Button(text="ºF --> ºC", command=convertir)
- boton.place(x=80, y=80, width=120, height=40)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment