Advertisement
teslariu

sumador

Feb 13th, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Sumador
  5. import tkinter as tk
  6. from tkinter import ttk
  7.  
  8. def sumar():
  9.     global total
  10.     suma = float(a.get()) + float(b.get())
  11.     total.set(str(suma))
  12.    
  13.  
  14. ##########  COMIENZO DEL PROGRAMA ##################
  15.  
  16.  
  17. ventana = tk.Tk()
  18. ventana.title("SUMADOR")
  19. ventana.config(width=400, height=800)
  20.  
  21. total = tk.StringVar()
  22. total.set("0")
  23.  
  24. label = ttk.Label(text="SUMADOR")
  25. label.place(x=120, y=10)
  26.  
  27.  
  28. ##### campo nombre #################
  29. a = ttk.Entry()
  30. a.place(x=120, y=70)
  31. label = ttk.Label(text="Primer sumando")
  32. label.place(x=10, y=70)
  33.  
  34.  
  35. ###### campo email ###############
  36. b = ttk.Entry()
  37. b.place(x=120, y=120)
  38. label = ttk.Label(text="Segundo sumando")
  39. label.place(x=10, y=120)
  40.  
  41. ###### campo nacionalidad ###########
  42. resultado = tk.Entry(
  43.                         textvariable=total,
  44.                         font = ('arial',20,'bold'),
  45.                         justify = "right",
  46.                         width=8,
  47.                         state = tk.DISABLED
  48.                     )
  49.                    
  50. resultado.place(x=120, y=170)
  51. label = ttk.Label(text="Suma")
  52. label.place(x=10, y=170)
  53.  
  54.  
  55. boton = ttk.Button(text="Sumar", command=sumar)
  56. boton.place(x=90, y=220)
  57.  
  58.  
  59.  
  60.  
  61.  
  62. ventana.mainloop()
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement