Advertisement
teslariu

sumador

Jun 23rd, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import tkinter as tk
  5. ventana = tk.Tk()
  6. ventana.config(width=400, height=600, bg="slate gray")
  7. ventana.title("Ventana")
  8.  
  9. def sumar():
  10.     a = float(caja_a.get())
  11.     b = float(caja_b.get())
  12.     suma = a + b
  13.     total.set(str(suma))
  14.    
  15. total = tk.StringVar()    # total = "0"
  16. total.set("0")
  17.  
  18. caja_a = tk.Entry(font = ["arial",15,"bold"], justify="right")
  19. caja_a.place(x=20, y=50, width=100, height=25)
  20.  
  21. caja_b = tk.Entry(font=["arial",15,"bold"], justify="right")
  22. caja_b.place(x=220, y=50, width=100, height=25)
  23.  
  24. caja_c = tk.Entry(
  25.                 font =["arial",15,"bold"],
  26.                 justify="right",
  27.                 state= tk.DISABLED,
  28.                 textvariable = total,
  29.                 )
  30.                
  31.                            
  32.                
  33.                
  34. caja_c.place(x=150, y=100, width=100, height=25)
  35.  
  36. boton = tk.Button(text="Sumar", command=sumar)
  37. boton.place(x=150, y=200, width=100, height=40)
  38.  
  39.  
  40.  
  41. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement