Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import tkinter as tk
- from tkinter import ttk
- ventana = tk.Tk()
- ventana.title("sumador")
- ventana.config(width=400, height=300)
- def sumar():
- global resultado
- primer_sumando = float(a.get())
- segundo_sumando = float(b.get())
- total = primer_sumando + segundo_sumando
- resultado.set(str(total))
- ########### comienzo programa principal ##############
- resultado = tk.StringVar()
- resultado.set("0")
- ##### campo primer sumando a ################
- a = ttk.Entry(justify = "right",)
- a.place(x=10, y=10, width=200, height=25)
- etiqueta = ttk.Label(text="Primer sumando")
- etiqueta.place(x=220, y=10)
- ##### campo segundo sumando b ################
- b = ttk.Entry(justify = "right",)
- b.place(x=10, y=50, width=200, height=25)
- etiqueta = ttk.Label(text="Segundo sumando")
- etiqueta.place(x=220, y=50)
- ##### campo pantalla de resultados ################
- pantalla = ttk.Entry(textvariable=resultado, justify = "right", state = tk.DISABLED)
- pantalla.place(x=10, y=90, width=200, height=25)
- etiqueta = ttk.Label(text="Total de la suma")
- etiqueta.place(x=220, y=90)
- # boton suma
- boton = ttk.Button(text="Sumar", command=sumar)
- boton.place(x=50, y=130)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement