Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Script que implementa un convertidor de temperaturas de ºF a ºC y viceversa
- import tkinter as tk
- def pasar_a_celsius():
- caja_celsius.delete(0,tk.END)
- temp = (int(caja_farenheit.get()) - 32) / 1.8
- caja_celsius.insert('insert',f"{temp:.1f}")
- def pasar_a_farenheit():
- caja_farenheit.delete(0,tk.END)
- temp = int(caja_celsius.get()) * 1.8 + 32
- caja_farenheit.insert('insert',f"{temp:.1f}")
- ventana = tk.Tk()
- ventana.config(width=400, height=200)
- ventana.title("Conversor de temperaturas")
- ventana.minsize(320,120)
- # Campo Celsius
- etiqueta = tk.Label(text="ºC")
- etiqueta.place(x=25, y=25)
- caja_celsius = tk.Entry()
- caja_celsius.place(x=70, y=25, width=50, height=25)
- # Campo email
- etiqueta = tk.Label(text="ºF")
- etiqueta.place(x=175, y=25)
- caja_farenheit = tk.Entry()
- caja_farenheit.place(x=220, y=25, width=50, height=25)
- boton = tk.Button(text="ºC -> ºF", command=pasar_a_farenheit)
- boton.place(x=40, y=80, width=70, height=30)
- boton = tk.Button(text="ºF -> ºC", command=pasar_a_celsius)
- boton.place(x=190, y=80, width=70, height=30)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement