teslariu

cal_tkinter

Jan 18th, 2021
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """ Programa que implementa una calculadora de sumas con pantalla"""
  5.  
  6. import tkinter as tk  
  7.  
  8.  
  9.  
  10. ventana = tk.Tk()
  11.  
  12. ventana.config(width=400, height=300)
  13. ventana.title("Sumador")
  14.  
  15. def sumar():
  16.     suma_total = float(caja_A.get()) + float(caja_B.get())
  17.     total.set(str(suma_total))
  18.    
  19.  
  20. total = tk.StringVar()
  21. total.set("0")
  22.  
  23. boton = tk.Button(text="SUMAR", command=sumar)
  24. boton.place(x=20, y=50, width=100, height=30)
  25.  
  26. etiqueta = tk.Label(text="Primer sumando:")
  27. etiqueta.place(x=20, y=90)
  28.  
  29. caja_A = tk.Entry()
  30. caja_A.place(x=140, y=90, width=50, height=25)
  31.  
  32. etiqueta = tk.Label(text="Segundo sumando:")
  33. etiqueta.place(x=20, y=140)
  34.  
  35. caja_B = tk.Entry()
  36. caja_B.place(x=140, y=140, width=50, height=25)
  37.  
  38. etiqueta = tk.Label(text="SUMA:")
  39. etiqueta.place(x=20, y=190)
  40.  
  41. pantalla = tk.Entry(textvariable = total)
  42. pantalla.place(x=140, y=190, width=50, height=25)
  43.  
  44.  
  45. ventana.mainloop()
  46.  
Advertisement
Add Comment
Please, Sign In to add comment