Advertisement
teslariu

conversor Temp

Sep 8th, 2022
1,128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import tkinter as tk
  5.  
  6. def convertir_a_C():
  7.     caja_gradosC.delete(0,tk.END)
  8.     temp = (float(caja_gradosF.get()) - 32) / 1.8
  9.     caja_gradosC.insert(1,f"{temp:.1f}")
  10.    
  11. def convertir_a_F():
  12.     caja_gradosF.delete(0,tk.END)
  13.     temp = float(caja_gradosC.get()) * 1.8 + 32
  14.     caja_gradosF.insert(1,f"{temp:.1f}")
  15.    
  16.  
  17.  
  18. ventana= tk.Tk()
  19. ventana.config(width=500, height=150)
  20. ventana.resizable(0,0)
  21. ventana.title("Conversor de grados ° ")
  22. #ventana.iconbitmap("nombre del icono .ico")
  23.  
  24. # Campo grados C°
  25. etiqueta = tk.Label(text="Grados C°")
  26. etiqueta.place(x=40, y=30)
  27. caja_gradosC = tk.Entry()
  28. caja_gradosC.place(x=110, y=30, width=80, height=25)
  29.  
  30. # Campo grados F°
  31. etiqueta = tk.Label(text="Grados F°")
  32. etiqueta.place(x=280, y=30)
  33. caja_gradosF = tk.Entry()
  34. caja_gradosF.place(x=350, y=30, width=80, height=25)
  35.  
  36. # Creo un botón C° A F°
  37. boton = tk.Button(text="C°>>F°", command=convertir_a_F)
  38. boton.place(x=80, y=90, width=80, height=25)
  39.  
  40. # Creo un botón F° A C°
  41. boton = tk.Button(text="F°>>C°", command=convertir_a_C)
  42. boton.place(x=320, y=90, width=80, height=25)
  43.  
  44. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement